Lewis Hamilton beat teammate Nico Rosberg to pole position for the Spanish Grand Prix in a thrilling session dominated by the Mercedes duo.
Hamilton made a mistake in his first run in Q3 and lost over a second, but fought back in his final run and set a best time of 1:22.000 to outpace Rosberg by 0.280s, securing his third pole of the year and the 52nd of his career.
Daniel Ricciardo was a sensational third for Red Bull, albeit over six tenths of a second behind Hamilton.
Teammate Max Verstappen finished in fourth in his first qualifying in the Red Bull. The Dutchman was four tenths off Ricciardo's pace.
Ferrari had a very poor day, with Kimi Raikkonen and Sebastian Vettel sharing the third row of the grid, over a second off the pace.
Valtteri Bottas was seventh for Williams, ahead of Carlos Sainz in the quickest Toro Rosso and Force India's Sergio Perez.
Much to the delight of the local crowd, Fernando Alonso will start from 10th position.
The result means it is the first time since 2014 than a McLaren is in the top 10 in qualifying on merit.
Hamilton finally showed Mercedes' real pace and set a blistering laptime to go quickest in Q2 with a 1:22.159, a lap nearly a full second quicker than the previous best seen this weekend until that point.
The Briton finished six tenths ahead of Rosberg.
Nico Hulkenberg will start from 11th place after failing to reach Q3, the German finishing ahead of Jenson Button, who also missed the cut in the second McLaren.
Daniil Kvyat, in his first qualifying session with Toro Rosso this year, was the only of the Red Bull drivers to fail to reach the top 10.
The Russian will start from 13th after being some three tenths slower than Sainz in the second segment.
Romain Grosjean put the quickest Haas in 14th position, two places ahead of teammate Esteban Gutierrez.
The Haas duo were split by the top Renault, driven by Kevin Magnussen.
Rosberg set the quickest time of the weekend (1:23.002) with apparent ease in the first qualifying segment, the German over two tenths ahead of Hamilton as the Ferraris had a slow start.
Raikkonen finished fifth ahead of Vettel, both Ferraris outpaced by the Red Bull drivers.
At the back of the field, there was massive disappointment for Felipe Massa, who was knocked out in Q1, the Brazilian finishing down in 18th position, behind the second Renault of Jolyon Palmer, another of the men who did not make it to Q2.
Palmer came close to making it trough, however, but a last-gasp effort from Button relegated him to 18th.
Marcus Ericsson outqualified Sauber teammate Felipe Nasr, the Swiss squad's duo sharing the penultimate row of the grid.
The Manors qualified last, Pascal Wehrlein beating Rio Haryanto by less than two tenths of a second.
|3||Daniel Ricciardo||Red Bull Racing||1:23.749||1:23.585||1:22.680||12|
|4||Max Verstappen||Red Bull Racing||1:23.578||1:23.178||1:23.087||12|
|8||Carlos Sainz Jr.||Toro Rosso||1:24.496||1:24.077||1:23.643||12|
|9||Sergio Perez||Force India||1:24.698||1:24.003||1:23.782||16|
|11||Nico Hulkenberg||Force India||1:24.463||1:24.203||13|
|13||Daniil Kvyat||Toro Rosso||1:24.696||1:24.445||11|
|14||Romain Grosjean||Haas F1 Team||1:24.716||1:24.480||12|
|15||Kevin Magnussen||Renault F1 Team||1:24.669||1:24.625||12|
|16||Esteban Gutierrez||Haas F1 Team||1:24.406||1:24.778||12|
|17||Jolyon Palmer||Renault F1 Team||1:24.903||6|
|21||Pascal Wehrlein||Manor Racing||1:25.745||9|
|22||Rio Haryanto||Manor Racing||1:25.939||9|