Lewis Hamilton hailed a monumental comeback by his Mercedes team after he secured a surprise second on the grid for Sunday's Azerbaijan Grand Prix.
The seven-time world champion headed into qualifying at the Baku street circuit facing the likelihood of starting way down the order, with the Silver Arrows desperately slow.
But Hamilton managed not only to steal a spot on the front row, but he will also line up one place ahead of his Red Bull rival Max Verstappen.
Ferrari's Charles Leclerc clinched his second pole in as many rounds during a frenetic qualifying session which saw the red flag deployed on four occasions after a quarter of the grid crashed out.
Yet, it was Hamilton, only 11th in practice on Friday, celebrating like the driver on pole following a qualifying which could prove pivotal in his bid for a record eighth title.
"We definitely were not expecting that," said Hamilton, moments after stepping out of his Mercedes.
"This is such a monumental result for us because we have been struggling like you wouldn't believe.
"We kept our composure and continued to have difficult discussions in the background, challenging one another and never taking no for an answer.
"We have made so many changes over these two days. It has been so difficult but the work overnight and between practice and qualifying was amazing.
"It is the biggest challenge we have had for a long time, trying to find out what the car wants because it has not been happy all weekend, it has been a disaster.
"But this result puts us in a much better position for the race than we anticipated yesterday. We can take the fight to these guys tomorrow."
Hamilton, four points behind Verstappen in the standings, has been struggling to get his tyres in the correct temperature window at the unique 3.73 mile course on the Caspian Sea.
But a series of set-up changes ahead of qualifying swung the balance of power in Hamilton's favour.
After his first run in Q3, he finished 0.232 seconds adrift of Leclerc, one tenth ahead of Verstappen, and that was how the order would remain.
Rookie Yuki Tsunoda crashed out at the third corner with little more than a minute of qualifying remaining, preventing the other drivers from completing their final runs, just as in Monaco a fortnight earlier when Leclerc hit the barriers.
"It was just a stupid qualifying," said Verstappen, disappointed that he could not post a final lap.
"Everything was working out fine but this s*** happens all the time in Q3."
Pierre Gasly starts fourth for AlphaTauri with Leclerc's team-mate Carlos Sainz, who also crashed at Turn 3 after he was distracted by Tsunoda's accident, fifth.
Lando Norris finished sixth but will start ninth after he was penalised three positions for staying out on track when the first red flag was issued.
Q1 took almost 40 minutes, rather than the scheduled 18 to complete, following two stoppages. First, Lance Stroll crashed out in his Aston Martin.
The Canadian driver hit the wall on the exit of Turn 15, with the impact ripping off his front wing.
Following an 11-minute delay, Q1 restarted but soon Antonio Giovinazzi then fell victim to Turn 15 when he also ended up in the barriers.
The delays allowed Williams to complete an engine change on George Russell's car after he broke down in final practice, and the Englishman repaid their impressive efforts by progressing to Q2 and finishing 15th.
Q2 then came to a premature end following the day's third red flag.
Daniel Ricciardo, who has endured a difficult start to life at McLaren following his transfer from Renault, carried too much speed into the left-handed Turn 3.
He crashed into the wall, sustaining serious damage to the front of his car, but the Australian was unharmed in the accident. He will line up only 13th for Sunday's race.