Daniel Ricciardo dashed Red Bull team mate Max Verstappen's hopes of becoming Formula One's youngest ever pole-sitter on Saturday while championship leader Lewis Hamilton qualified third for Mercedes at the Mexican Grand Prix.
Hamilton, who need only finish seventh on Sunday to secure his fifth title with two races to spare, will have Ferrari rival Sebastian Vettel alongside on the second row.
Vettel, 70 points behind Hamilton, must win the race to have any chance of denying the Briton.
Last year's race winner Verstappen, 21, had dominated all three practice sessions and was fastest before Ricciardo produced a scorching effort at the high-altitude Hermanos Rodriguez circuit.
The front row lockout was Red Bull's first since the US Grand Prix of 2013 but second place still left the Dutch youngster feeling sore.
"I knew it was there somewhere. We hadn't had the cleanest run through practice and I just knew putting the lap together would be crucial as always," said Ricciardo, who whooped in delight as he realised what he had done.
"I knew the pace was in the car, Max showed that all weekend from start to finish.
"I still wasn't convinced, it wasn't the cleanest (lap), but once I heard I got pole I got to relax a little," added the Australian, who is leaving Red Bull for Renault at the end of the year.
The pole was only the third of Ricciardo's career and both of those previous ones came in the tight and twisty confines of Monaco.
Verstappen lost out by 0.026, with Ricciardo setting a track record time of one minute 14.759 seconds, and he did not try and hide his disappointment.
"The whole qualifying was crap," the youngster told the global television audience. "We tried to make the best of it, I thought we had enough but it's still good to be second."
Behind the Red Bulls all eyes will be on the title contenders, with Hamilton in the stronger position after a difficult few days for Mercedes.
"I was not expecting to be up as high as we have done," said the Briton. "The team did a great job yesterday, this was as good as I could get.
"You saw what happened last year with the red car (Ferrari) behind, so it depends how we get away. We will get a good tow from the two in front so hopefully I can gain a position."
Hamilton won his fourth title in Mexico last year after starting third and then having to fight back from last to ninth following an opening lap collision with Vettel, who had been on pole but lost out to Verstappen.
Vettel, who had looked good for the front row before Ricciardo and then Hamilton pushed him down, said he had not managed to get a clean lap in.
"I think we got more or less everything out of the car, dropping back to fourth from second is not satisfying but we'll see what we can do from there," he said.
"We have good straight line speed so maybe that will help. We probably have the best reliability so far, the Red Bull's are fast so they will be hard to beat but they might beat themselves."
Verstappen had an hydraulics problem in Friday's second practice while Ricciardo has endured seven retirements in 18 races so far.
Hamilton's team mate Valtteri Bottas was fifth fastest, with Mercedes replacing his car's engine between final practice and qualifying, and ahead of fellow-Finn Kimi Raikkonen in sixth place for Ferrari.
The Renault pair of Nico Hulkenberg and Carlos Sainz were seventh and eighth, with Sauber's Charles Leclerc and Marcus Ericsson filling the next row.
There was disappointment for the Mexican crowd with the country's sole driver Sergio Perez qualifying only 13th.