Lewis Hamilton snatched pole position for the Portuguese Grand Prix from team-mate Valtteri Bottas in a thrilling end to an unusual qualifying.
Hamilton and Bottas ran theoretically slower medium tyres to set their times and a key strategy call by the Briton could have made the difference.
Hamilton chose to do two hot laps at the climax to Bottas' one, and the lead swapped between them as it played out.
Red Bull's Max Verstappen took third, from Charles Leclerc's Ferrari.
Hamilton ended up beating Bottas by 0.101 seconds at the end of an unpredictable and exciting session. It was the 97th pole position of the world champion's career.
How did Hamilton nick it?
Bottas had appeared to have the edge on Hamilton through the weekend, but as so often the six-time champion came good at the end when it mattered.
In the final session, the Mercedes drivers ran the soft tyres at the start of final qualifying, with Bottas going fastest, and then switching to the mediums at the end.
Bottas said he chose to do one timed lap at the end of the session, while Hamilton picked two, with a cool-down in between.
Hamilton set the pace on his first lap, before Bottas re-took first with his single lap, and then Hamilton leapfrogged back ahead with the last lap of the session.
"In the end, I should have gone for two," a rueful Bottas said afterwards.
Verstappen was less than 0.2secs off pole in the Red Bull, a promising position for him, while Leclerc was just 0.186secs behind the Red Bull, after an outstanding performance in the Ferrari, helped by the latest in a series of aerodynamic upgrades on the car.
Hamilton said: "We have a great car but you have to drive the nuts off it to pull out a lap. Valtteri has been so quick and I have been digging and digging to try to find the extra time.
"I chose to do three laps to have a stab at beating his time. He chose one and I thought: 'This could provide me with an opportunity,' and it worked."
Leclerc's team-mate Sebastian Vettel was down in 15th place, 0.552secs off the Monegasque in second qualifying, which the German did not progress beyond.
"It's not just getting beaten," Vettel said. "It is almost like a different league... I try everything I can. The laps I am satisfied with are still too slow. I try to bring the best out of myself and the car. I can't do more than that."
Leclerc is also starting the race on the medium tyre, having used it to go through Q2, the same strategy choice as Mercedes at the front.
Behind Leclerc, Racing Point's Sergio Perez was fifth, ahead of the second Red Bull of Alex Albon, the McLarens of Carlos Sainz and Lando Norris, Pierre Gasly's Alpha Tauri and Renault's Daniel Ricciardo, who did not take part in Q3 after damaging his rear wing with a light crash at the end of the second session.
George Russell starts an impressive 14th in the Williams, keeping up his record of never having been out-qualified by a team-mate in F1.