Lewis Hamilton snatched a dramatic pole position for Sunday's Monaco Grand Prix with an all-time circuit record lap in the final seconds to outpace Mercedes team-mate Valtteri Bottas by 0.086 seconds.
The defending five-time champion and series leader clocked an unprecedented lap in 1min 10.166sec to end Bottas' run of three successive poles as Mercedes, mourning the death this week of non-executive chairman Niki Lauda, produced a record-equalling 62nd front row lockout.
It was an emotional Hamilton's second pole in Monaco and the 84th of his career as he dug deep in the final seconds to find the speed required to grab the prime grid position from his team-mate.
"Whoooah!" shouted Hamilton on team radio. "That's what I am talking about...."
Max Verstappen was third for Red Bull ahead of four-time champion Sebastian Vettel of Ferrari, Pierre Gasly in the second Red Bull and Kevin Magnussen for Haas.
Last year's race winner Daniel Ricciardo was seventh for Renault ahead of Daniel Kvyat of Toro Rosso, Carlos Sainz of McLaren and Alex Albon in the second Toro Rosso.
"This is the race that every driver dreams of, even as a kid," said Hamilton.
"We've arrived with a great car, a great battle with Valtteri and I think the desire and the will to get this pole. I've had to dig deeper than ever before.
"We all take our cars, fast or slow, to the limit and here, at the limit, it's like wrestling a bull. I had an oversteer moment in the Rascasse and I just held on."
Bottas said: "I'm disappointed. I felt after the first lap there were plenty of places to improve, but I had traffic and couldn't get the tyres up to temperature."
Luckless local hero Charles Leclerc qualified 16th after a strategic muddle by Ferrari in the opening part of qualifying.
After Vettel's crash in the morning's final free practice session, Q1 began cautiously in the warmest conditions of the weekend, the track registering 44 degrees Celsius under a hazy sun.
Mercedes, as they feared, found the conditions testing and required longer to bring their tyres alive, but were soon first and third with Bottas and Hamilton sandwiching Verstappen.
Vettel then bounced his left rear wheel off the barriers in the swimming pool complex, requiring a rapid pit-stop.
He emerged with seconds remaining on shiny new 'softs' as Hamilton topped Bottas, but faced a desperate rush to re-climb from 17th - and exceeded expectations by going fastest in a frantic finale.
Leclerc was left standing in the Ferrari garage as he tumbled down the timesheets to finish 16th, the team not keeping him out after he missed a signal to the weighbridge.
He was pushed back to the scales, to avoid any penalty, but it was another example of Ferrari's operational and decision-making failings.
"I need explanations," said Leclerc. "The problem was not the weighbridge and I have had no real answers. It is very difficult to take as we had plenty of time and enough fuel... Now, I must take risks in the race."
Out with an upset Leclerc, who was fastest in the morning, went Sergio Perez, Lance Stroll, George Russell and Robert Kubica.
Q2 then began with a blistering record lap from Bottas in 1:10.701. Hamilton was one-tenth down for second with Verstappen third ahead of Kvyat.
With four minutes remaining, all 15 returned for a final flurry in which Verstappen topped Bottas in 1:10.618 - a record that suggested he might repeat Red Bull's success, with Ricciardo, last year.
Out went Nico Hulkenberg, Lando Norris, Romain Grosjean, Kimi Raikkonen and his Alfa team-mate Antonio Giovinazzi, all bickering about the traffic and blocking before the top ten shootout.
On his first run, Bottas laid down a marker in a record 1:10.252 to lead the way ahead of Verstappen as Hamilton struggled for a clean lap, but all that changed on his final run.