Lewis Hamilton mastered the difficult conditions that struck the Hungaroring during qualifying to take pole position for Sunday's Hungarian Grand Prix, leading a Mercedes 1-2.
Hamilton crossed the line last as conditions gradually improved, allowing him to beat team-mate Valtteri Bottas to the top spot by just 0.260s.
Hamilton's main championship rival, Sebastian Vettel, starts fourth in an all-Ferrari second-row with Kimi Raikkonen pipping his team-mate by just 0.024s.
Although the conditions didn't bring an unusual top four, fifth onwards was varied as Renault's Carlos Sainz completed the top five ahead of Toro Rosso's Pierre Gasly.
Red Bull's leading driver was Max Verstappen who finished seventh quickest, a massive 2.3 seconds adrift of Hamilton. But it was more than team-mate Daniel Ricciardo could manage. The Australian initially struggled to escape Q1 as his soft tyres were no match for the ultrasofts everyone else chose to run, all keen to get a quick lap in before the rain struck the circuit.
Whilst the rain held off for Q1, huge claps of thunder and flashes of lighting filled the sky. Ricciardo just scraped through the session, but lacked pace in Q2 and finished 12th behind McLaren's Fernando Alonso.
Brendon Hartley and the Haas duo led by Kevin Magnussen completed the top ten.
Renault too suffered mixed fortunes as Nico Hulkenberg could only manage P13 ahead of Sauber's Marcus Ericsson, who made yet another Q2 appearance, followed by Lance Stroll in P15.
The Canadian was the only driver to find the wall during the session after he span and his front-wing clattered the barrier, bringing his session to a premature end. Kimi Raikkonen span moments later but was able to keep going.
Stoffel Vandoorne was 16th leading Charles Leclerc and a disappointing result for the Force Indias which were only 18th and 19th – their first failure to escape Q1 with both cars in three seasons.