Mercedes head of motorsport Toto Wolff could hardly believe it as he watched from the team motorhome, clutching his head in disbelief as Hamilton beat Mercedes teammate Valtteri Bottas' time to secure a record-extending 77th pole position in Formula One.
Hamilton put his exceptional performance in difficult track conditions down to an intuitive feel for the car.
"It is really difficult to arrive in a corner and know how much grip you are going to have," Hamilton said. "You're just looking for a clean line and really tip-toeing around all the corners. It's a bit like doing ballet — not that I've done ballet — but you're tip-toeing and feeling the movement of the car."
Just moments earlier, Mercedes' rival Ferrari was 1-2 with Kimi Raikkonen ahead of Sebastian Vettel.
The scenario changed in a matter of seconds, and Vettel will start fourth behind Raikkonen.
Earlier, the third and final practice was held in warm and sunny conditions, but by the time qualifying started there was rain, thunder, and even some lightning.
As Ferrari became more cautious, Mercedes stepped it up."We couldn't have expected this," Hamilton said.
"The Ferraris were quicker all weekend, but the heavens opened and it was fair game."
Bottas finished second to Hamilton at the rain-soaked German GP last weekend, receiving team orders near the end to hold position and not to try to attack Hamilton.
"We are free to fight, so I'm looking forward to it," Bottas said of Sunday's race.
Although the Finnish driver regularly insists he is on an equal footing with Hamilton, the widely perceived view is that he is effectively No. 2. The narrow Hungaroring track, nestled in rolling holes on the outskirts of Budapest, is among the most difficult circuits in F1 to overtake. It is considered more favorable to cars with a strong downforce like Red Bull and Ferrari.
It certainly looked that way when the weather was warm and things were going Ferrari's way, which explains Wolff's unchecked delight at the end of qualifying.
"He wasn't particularly happy with his own driving ... then come qualifying, the session that matters, he was there," Wolff said. "That is a great champion's ability."
Vettel was fastest in the final practice in dry conditions and also in Friday's second practice. Hamilton did not finish higher than fourth in all three practice runs.
But when the weather changed, so did the fortunes of four-time F1 champions Hamilton and Vettel.
"In the wet conditions we aren't as confident as in the dry," Vettel said, candidly. "In the dry we were in control."
Red Bull driver Daniel Ricciardo was fastest in the first practice, but only 12th in qualifying after his team misjudged which tires to use when it started raining. Teammate Max Verstappen could manage only seventh behind French driver Pierre Gasly's Toro Rosso car and the Renault of fifth-place Carlos Sainz.
Verstappen was cleared of impeding French driver Romain Grosjean following a steward's investigation.Vettel is battling fiercely for the title with Hamilton, who won last Sunday from 14th place on the grid.
Vettel was cruising in Germany, but crashed toward the end to hand Hamilton the championship lead by 17 points after 11 of 21 races.Hamilton looked on the back foot in Hungary practice.The British driver complained on team radio about a lack of grip, having also been concerned with his tires.
Early into qualifying, Hamilton even feared his tires were "falling apart" but once again he proved himself to be the best in wet conditions.