Championship leader Lewis Hamilton put his car on pole in Hungary but rival Sebastian Vettel could only qualify in fourth in the wet.
Hamilton’s championship rival Sebastian Vettel was expected to be the fastest in the dry, but, as ever, Hamilton turned on the style when the heavens opened.
The Englishman beat team-mate Valtteri Bottas by a quarter of a second to the top slot on the grid, while Ferrari’s Kimi Raikkonen third.
Vettel, 17 points behind Hamilton in the championship, finished only fourth, more than half-a-second down on his rival.
Dark clouds hovered over the Hungaroring before large claps of thunder ensured a downpour was imminent.
Moments later, the rain arrived to ensure the first wet qualifying session since last September’s Italian Grand Prix.
On that day, Hamilton prevailed with a remarkable lap, and here the Briton was at it again to prove his credentials in the slippery conditions.
Vettel, who crashed out from the lead of his home race in Germany last week, appeared cautious, and will now have his work cut out from fourth at a track where overtaking is difficult.
“We couldn’t have expected this because Ferrari have been quickest all weekend,” Hamilton, only fourth in final practice, said. “We were going to try and do our best to be as close to them as possible, but then the heavens opened and it was fair game.
“It is so tricky out there. Towards the end it was getting really wet and it is difficult to arrive at the corner and know how much grip you are going to have.
“That was massively challenging. You are tip-toeing around like a ballerina. We are in a great position so we are going to do our best to keep the red guys behind us.”
Red Bull driver Daniel Ricciardo was the biggest victim to fall foul to the changeable conditions.
The Australian failed to get in a good enough lap at the start of Q2, and as the rain intensified, he was unable to haul his car into the top-10 shootout. He qualified only 12th.
Fernando Alonso was on hand to state just how wet the track had become when asked by his race engineer if he should stick to intermediate tyres or change to the full wet rubber.
“We should go to the garage,” he said. “Put on whatever you like. The last sector is impossible. Even if you put on a rocket ship we will [fail to improve on] 11th.”
And that is where the double world champion, who on Sunday turns 37, will start.
His team-mate Stoffel Vandoorne, who has been desperately out of sorts in recent races, was 16th.
Cash-strapped Force India were placed in administration on Friday evening following a court hearing, and their problems away from the track were replicated on it here.
Esteban Ocon and Sergio Perez, the Mexican driver who initiated the legal proceedings with his sponsors owed more than £3million, fell at the first hurdle and will start only 18th and 19th of the 20 runners.