Lewis Hamilton stunned Valtteri Bottas to snatch pole position for Formula 1's 2020 Portuguese Grand Prix, after Bottas had topped every practice session and led Q3 after the opening runs.
Max Verstappen qualified third for Red Bull, ahead of Ferrari's Charles Leclerc.
At the end of the qualifying session at Portimao, which was delayed by 30 minutes so a drain cover at Turn 14 that had been dislodged at the end of FP3 was repaired, the Mercedes drivers made the unusual decision to go for their final runs on the medium tyres.
Bottas led the way on the 1m16.986s that he had set on the softs, with Hamilton needing to find 0.087s.
The world champion then left his garage with over four minutes of the session remaining on the harder rubber, which he used to take first place with a 1m16.934s.
Bottas wrestled back the top spot with a 1m16.754s, with Verstappen, still on the softs, then getting ahead of Hamilton.
But the world champion had enough time and fuel to go for a second run, which he used to leap from third to pole with a 1m16.652s.
The two Mercedes drivers will also start on the race on the medium tyres, handing them a likely strategy advantage over Verstappen.
Leclerc, who also came through Q2 on the mediums, took fourth with a late improvement on his final lap, ending up ahead of Sergio Perez, and the pair of them shuffling Alex Albon down to sixth in the other Red Bull.
The McLarens of Carlos Sainz Jr and Lando Norris took seventh and eighth, with Pierre Gasly ninth for AlphaTauri.
Gasly faces a post-qualifying investigation alongside Perez regarding an issue in Q3 at Turn13.
Daniel Ricciardo had only just squeaked into Q3 after he spun off going through the high-speed right of Turn 11 as he passed one of the Mercedes cars and his team-mate Esteban Ocon.
The Australian driver slid backwards through the gravel and touched the wall with the rear of his Renault, but was quickly able to drive away.
However, Renault could not fix the necessary repairs in time for Ricciardo to set a time in Q3 and he will start 10th as a result.
Ocon had already failed to improve on his final lap and was knocked out in 11th as a result, ahead of Lance Stroll and Daniil Kvyat.
George Russell, who had nipped through to Q2 for the seventh time in 2020 with a last-gasp improvement in Q1, beat Sebastian Vettel to P14.
Vettel was also lapping on the medium tyres thoughout Q2, but a lock-up at Turn 3 and feeling his tyres "were not ready" on the new, low-grip surface at Portimao cost the Ferrari driver.
In Q1, which was delayed for 30 minutes by the track repair work, Russell improved with the last timed lap of the opening segment, setting personal bests in all three sectors, as he therefore knocked Kimi Raikkonen out in 16th.
Behind Raikkonen came his team-mate Antonio Giovinazzi, while Romain Grosjean was shuffled down from P15 to P18 in the closing moments of Q1 as he could not improve - and not in any individual sector, either - on his final lap.
Kevin Magnussen finished P19, while Nicholas Latifi brought up the rear of the field in 20th, as he too failed to go faster at any stage on his final lap.
F1 Portuguese GP qualifying results
|3||Max Verstappen||Red Bull/Honda||0.252s|
|5||Sergio Perez||Racing Point/Mercedes||0.571s|
|6||Alexander Albon||Red Bull/Honda||0.785s|
|7||Carlos Sainz Jr.||McLaren/Renault||0.868s|
|12||Lance Stroll||Racing Point/Mercedes||0.974s|
|16||Kimi Raikkonen||Alfa Romeo/Ferrari||1.549s|
|17||Antonio Giovinazzi||Alfa Romeo/Ferrari||1.671s|
Autosport has produced a standalone special magazine to celebrate our 70th birthday. All current print subscribers will receive a copy for free. To order your copy of the 196-page Autosport 70th Anniversary issue, please go to: autosport.com/autosport70th