Lewis Hamilton has claimed his 77th Formula 1 pole after a dramatic qualifying session at the Hungarian Grand Prix dominated by changeable conditions.
A late lap from the Mercedes driver saw him move to the top of the timesheets, demoting team-mate Valtteri Bottas to second.
Kimi Raikkonen will start third after he looked likely to snag pole, only for the two Mercedes drivers to improve on their final flying laps.
Sebastian Vettel completed an all-Ferrari second row, the German struggling to match the pace of his team-mate in the final part of the session.
Daniel Ricciardo was caught out by the rapidly changing conditions, missing the cut at the end of Qualifying 2 and will start Sunday's race just 12th.
A damp circuit greeted drivers as qualifying began, and with rain forecast almost the entire field queued up at pit exit eager to bank an early lap before conditions worsened.
Carlos Sainz was the first to brave slick tyres, the Renault driver rocketing to the top of the time sheets.
The bulk of the field soon followed as the order began to change with each car that crossed the line.
Vettel, who had fallen to 19th following his initial effort on intermediate tyres, was one of the last to start a flying lap as the conditions threatened to close in.
He improved to fourth while behind him on track Ricciardo was the last runner to attempt to set a lap on slick tyres, but could only manage the 17th best time.
The Australian had a set of soft compound tyres fitted, while every other car used a set of ultrasoft tyres.
He improved to 12th fastest on his second flying lap to escape the opening phase of qualifying as the sky began to darken once again.
In the chaos in the final moments both Force Indias were eliminated, with Esteban Ocon 18th and Sergio Perez 19th.
Stoffel Vandoorne just missed the cut for McLaren, as did Sauber's Charles Leclerc, while Sergey Sirotkin ended the day slowest of anyone in the Williams.
Conditions rapidly deteriorated as Qualifying 2 began, Vettel the only driver to head out on intermediate tyres as the rest of the field tip-toed around on slicks before immediately returning to the pits.
Lance Stroll lost the back end of his Williams and nosed into the barriers coming out of Turn 9 as conditions transformed from damp to drenched in a matter of moments.
The incident caught out Ricciardo, the Red Bull driver behind the spinning Stroll, missing his best opportunity for a competitive time.
Desperate to progress despite the conditions, the Australian was one of a number who attempted to improve their times in the closing minutes by using a set of the full wet tyres.
It proved a fruitless exercise, while he improved on his own time it left the Red Bull driver just 12th and eliminated.
Also out went Fernando Alonso, Nico Hulkenberg, Marcus Ericsson and Stroll, the latter not setting a lap time following his conversation with the barrier.
Verstappen was the first to begin a timed lap in Qualifying 3, the benchmark set at 1:38.923s by the Red Bull driver on a set of full wet tyres.
His time didn't last long, with both Mercedes drivers usurping the Dutchman, Hamilton ahead of Bottas but the pair split by less than a tenth of a second.
Vettel's first effort was two seconds off the pace, and while he improved at the second time of asking the Ferrari driver was still more than a second slower than Hamilton, who had also improved.
Raikkonen found more grip to improve to move up to the top of the time sheets with four minutes left in the session, the Fin's time four tenths quicker than anyone else had managed to that point in the session.
Vettel couldn't match his team-mate as he fitted a second set of tyres, improving to only second fastest.
They were both relegated by Bottas as the chequered flag fell, with Hamilton then going one better to confirm a Mercedes lock out of the front row.
Carlos Sainz finished the session fifth, Pierre Gasly sixth and Verstappen just seventh.
Berndon Harltley recorded his best Formula 1 starting position with eighth, ahead of the two Haas' of Romain Grosjean and Kevin Magnussen.
Dry conditions are expected to return in time for the race, which is set to begin at 2310 AEST on Sunday.
Result: Hungarian Formula 1 Grand Prix, Qualifying
Pos | Driver | Team | Time |
1 | Lewis Hamilton | Mercedes | 1:35.658 |
2 | Valtteri Bottas | Mercedes | 1:35.918 |
3 | Kimi Raikkonen | Ferrari | 1:36.186 |
4 | Sebastian Vettel | Ferrari | 1:36.210 |
5 | Carlos Sainz Jr. | Renault | 1:36.743 |
6 | Pierre Gasly | Toro Rosso Honda | 1:37.591 |
7 | Max Verstappen | Red Bull Renault | 1:38.032 |
8 | Brendon Hartley | Toro Rosso Honda | 1:38.128 |
9 | Kevin Magnussen | Haas Ferrari | 1:39.858 |
10 | Romain Grosjean | Haas Ferrari | 1:40.593 |
11 | Fernando Alonso | McLaren Renault | 1:35.214 |
12 | Daniel Ricciardo | Red Bull Renault | 1:36.442 |
13 | Nico Hulkenberg | Renault | 1:36.506 |
14 | Marcus Ericsson | Sauber Ferrari | 1:37.075 |
15 | Lance Stroll | Williams Mercedes | |
16 | Stoffel Vandoorne | McLaren Renault | 1:18.782 |
17 | Charles Leclerc | Sauber Ferrari | 1:18.817 |
18 | Esteban Ocon | Force India Mercedes | 1:19.142 |
19 | Sergio Perez | Force India Mercedes | 1:19.200 |
20 | Sergey Sirotkin | Williams Mercedes | 1:19.301 |