Lewis Hamilton eased to his tenth pole position of 2016 season in qualifying for the Mexican Grand Prix, but team-mate Nico Rosberg crucially grabbed second place at the death after struggling throughout the session.
Hamilton put in a 1:18.704 on his first run in Q3, and though he just missed out on an improvement with his final flying lap, he wound up fastest by two and a half tenths.
Rosberg was fourth heading into the closing stages of Q3 after a tricky afternoon for the championship leader, but he recovered to take second place with what could prove a vitally important lap.
Max Verstappen out-qualified Red Bull team-mate Daniel Ricciardo to take third place, within three tenths of Hamilton's benchmark, and the Bulls have an opportunity to grab the lead on the marathon 900-metre run towards turn one, starting on the faster supersoft tyres.
Nico Hulkenberg was arguably the star of qualifying as he edged the two Ferraris to claim a superb P5, with the Scuderia tumbling short of the potential they showed in practice. Kimi Raikkonen will start sixth, having got the better of team-mate and Friday-pace setter Sebastian Vettel.
Valtteri Bottas and Felipe Massa will line-up eighth and ninth, with Carlos Sainz rounding out the top ten after making the top-ten shoot-out for the second consecutive weekend.
Late improvements from the Williams duo dumped Fernando Alonso out of qualifying, while home favourite Sergio Perez missed out on a Q3 spot, comprehensively beaten by team-mate Hulkenberg.
Jenson Button, four tenths slower than Alonso, could only manage 13th, with Kevin Magnussen a solid 14th for Renault amid ongoing speculation surrounding his future.
Having impressively made Q2, Marcus Ericsson and Pascal Wehrlein could do no better than 15th and 16th respectively, with the latter hampered by his worn rubber.
Esteban Gutierrez's hopes of escaping Q1 elimination were dashed by a spin in the middle sector on his final flying lap, consigning the Mexican to P17 on home turf, with Daniil Kvyat a disappointing 18th for Toro Rosso.
Felipe Nasr was out-qualified by his team-mate for the fifth consecutive race and forced to settle for 19th, ahead of Esteban Ocon and Romain Grosjean, whose efforts were scuppered by the yellow flags following his team-mate's spin.
Renault's Jolyon Palmer did not take part in qualifying after sustaining chassis damage in final practice, and will start at the back of the grid.