Lewis Hamilton will start Sunday's Hungarian Grand Prix from pole position after topping the times in a wet qualifying session in Budapest.
The world champion had struggled in the dry practice sessions at the Hungaroring, but he excelled when rain arrived.
He beat Mercedes-GP teammate Valtteri Bottas to take the 77th pole of his career with a lap of 1 minute, 35.658 seconds.
Hamilton leads Sebastian Vettel by 17 points in the standings going into the last race before the summer break, and his German rival could only qualify fourth in his Ferrari.
For the first time since Australia, the opening race of the season, Vettel was out-qualified by his teammate Kimi Raikkonen, who took third place.
Carlos Sainz was fifth for Renault ahead of Pierre Gasly's Toro Rosso.
Red Bull Racing were the big losers of the day. On a track that they had been expected to excel at they could only qualify seventh and 12th respectively.
The 70-lap race begins at 5.10pm UAE time on Sunday.
____________
Read more:
Force India struggle in Hungary GP qualifying after being placed in administration
Preview: Vettel will remain Hamilton's focus in Hungary despite Red Bull threat
Graham Caygill: Title fight between Hamilton and Vettel as Bottas and Raikkonen receive team orders
____________