Lewis Hamilton took pole ahead of Valtteri Bottas as Mercedes took advantage of wet conditions to lock out the front row at the Hungarian Grand Prix.

Toto Wolff said he thought Mercedes' fortunes had changed after Hamilton and Bottas gave the Silver Arrows a one-two at Hockenheim last weekend following Sebatian Vettel's crash.

They were counting their blessings again on Saturday when the heavens opened at the Hungaroring, world champion Hamilton snatching pole with a final flying lap of one minute, 35.658 seconds.

Bottas had been sitting in provisional pole from Kimi Raikkonen, but championship leader Hamilton denied him by 0.260secs on a dramatic session with changing conditions.

Raikkonen had to settle for third following a poor last lap, while his Ferrari team-mate Vettel - 17 points adrift of the Brit in the title race - will start the final race before the mid-season break in fourth.

Carlos Sainz and Pierre Gasly secured impressive fifth and sixth spots on the grid respectively, while Max Verstappen was only seventh-fastest and Daniel Ricciardo 12th on a gloomy day for Red Bull, who had been tipped to shine in Hungary.

Vettel had been quickest in two of the three practice sessions and second in FP1, but it was the Mercedes duo that delivered on a soaked track after both Hamilton and Bottas had taken a spin at the chicane in the final practice session.

Rain came at just the right time for the Silver Arrows, with thunder rumbling around Budapest as Q1 got under way and Hamilton grasping his opportunity after heavy rain left the track sodden.

Brendon Hartley, Kevin Magnussen and Romain Grosjean completed the top 10, with Esteban Ocon and Sergio Perez coming a miserable 18th and 19th respectively a day after Force India entered administration.

PROVISIONAL CLASSIFICATION

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 (Renault) 1:36.743
6. Pierre Gasly (Toro Rosso) 1:37.591
7. Max Verstappen (Red Bull) 1:38.032
8. Brendon Hartley (Toro Rosso) 1:38.128
9. Kevin Magnussen (Haas) 1:39.858
10. Romain Grosjean (Haas 1:40.593