Lewis Hamilton took pole position at the Mexican Grand Prix as title rival Nico Rosberg left it late to join him on the front row.
Rosberg was slower than the Red Bulls throughout qualifying until the last lap, when he sneaked ahead of Max Verstappen and Daniel Ricciardo.
Rosberg was 0.254 seconds behind Hamilton and just 0.096secs quicker than Verstappen.
German Rosberg is 26 points ahead of Hamilton with 75 remaining this season.
He can afford to finish second twice and third once even if Hamilton wins all the remaining races and still win the title.
And if Rosberg wins on Sunday in Mexico City and Hamilton is 10th or lower, he will tie up the championship.
Sunday's race - expected to be attended by about 135,000 people - is live on the BBC Sport website and BBC Radio 5 live at 19:00 GMT.
Rosberg struggling to keep up with focused Hamilton
Rosberg had been struggling for pace all weekend in Mexico, lagging between 0.3-0.5secs behind Hamilton through all the sessions, including the first two parts of qualifying and the first laps of the top-10 shootout.
It appeared as if this might be the chance Hamilton needed to get a win under his belt with Rosberg struggling to hold off the Red Bulls and Ferraris.
But he managed to get it all together when it mattered and sneak on to the front row.
Considering the pressure, it was one of his most impressive performances of the season.
Ferrari go missing when it matters
Ferrari had also appeared to be in the mix up until the second part of qualifying. Sebastian Vettel was fourth fastest in Q2, 0.4secs quicker than Rosberg and running the same soft tyres as Mercedes.
The move was a strategic one, so Vettel and the Mercedes drivers can start the race on the soft tyre which is just as quick and much more durable than the super-soft.
But Ferrari's hopes of taking much advantage of the strategy faded with their pace in Q3. Vettel could manage only seventh fastest, one place and 0.005secs behind team-mate Kimi Raikkonen, who is also starting on the softs.
Red Bull, on the other hand, are optimistic of mixing it with Mercedes in the race following their decision to start on the super-softs.
"Very disappointed," said Vettel. "The car is quick. Q2 was a walk in the park with soft tyres. I had a much better feel than with the super-softs.
"It's clear that on the super-soft we did not make the step like everyone else. Everybody was improving by half a second; we didn't improve at all. That's why I'm so annoyed.
"We start where the car doesn't belong. We are quicker than most people, we should start second row and even have a crack at first row if everything goes well."
Meanwhile, the other Britons...
Both were beaten by Force India's Nico Hulkenberg, with Williams' Valtteri Bottas and Felipe Massa and Toro Rosso's Carlos Sainz completing the top 10.
Sainz pipped fellow Spaniard and friend Fernando Alonso of McLaren to the final top-10 place but Alonso sounded pleased to be 11th when talking to his engineer.
It puts him on the grippier side of the grid and with free choice of tyres for the start of the race.
Team-mate Jenson Button has never been on Alonso's pace all weekend and was 0.391secs adrift in 13th.
Fellow Briton Jolyon Palmer will start last after not taking part in qualifying because he damaged its chassis over a kerb in final practice and he needed a new monocoque for the race.
What they said
"It's always a tough battle," Hamilton said. "Trying to pull out the perfect laps when it counts is always a difficult thing. The track has got a lot better, there is more grip than last year and it feels more like a race track."
Rosberg said: "I'm still 0.25secs from Lewis. His lap was great, not mine. I put it together in the end and I am relatively pleased with that to make sure I am on the front row and give me a chance for the win.
Explaining his troubles through the weekend, he said: "It just took a bit longer to find the way [with the car], just generally with tyre temperatures. It's quite cold out there and that makes it a bit nervous. Just finding my way with that."
Hamilton, who is aiming for his second win in a week after his victory in Austin last Sunday, said: "There is no real tactic. I turned up to do the job and I will try to do the same thing as I did last week here."