Lewis Hamilton claimed his fourth pole position of the 2014 Formula 1 season by topping qualifying for the Spanish Grand Prix.
Hamilton was outpaced by Mercedes team-mate Nico Rosberg during the first two segments of qualifying, but delivered when it counted in Q3 to take pole by 0.168 seconds in a tense final-lap battle.
With Mercedes continuing to dominate, the rest were battling for third and it was Red Bull's Daniel Ricciardo who emerged as best of the rest, albeit a second off Hamilton.
Valtteri Bottas qualified fourth for Williams, comfortably ahead of Romain Grosjean, who continued the recent upward trend for the twin-tusk Lotus E22 with a season's best fifth place.
The two Ferraris lapped at a similar pace, ending up sixth and seventh with Kimi Raikkonen shading team-mate Fernando Alonso.
Jenson Button was eighth ahead of Felipe Massa, the latter looking set for a stronger grid position but for a disappointing Q3 lap.
Sebastian Vettel qualified 10th after being unable to complete a lap during Q3 thanks to his Red Bull grinding to a halt early in his run, prompting a brief red flag stoppage.
Nico Hulkenberg was fastest of the drivers to fail to make the top 10 shootout. He was bumped out of the Q3 slots by Bottas late on, albeit less than a tenth slower than home hero Alonso, who just scraped through.
The second Force India of Sergio Perez was 13th ahead of Daniil Kvyat and Esteban Gutierrez.
Behind them, Kevin Magnussen was classified 15th despite not running in Q2 with an engine problem striking his McLaren-Mercedes.
|Spanish GP qualifying reaction|
|Vettel gets five-place penalty|
|Alonso: gap to Mercedes biggest pain|
|Bottas: changes transformed weekend|
|Maldonado says crash "very strange"|
Jean-Eric Vergne was 16th after also not running, but he will start from the back of the grid thanks to a 10-place grid penalty for shedding a wheel during Friday afternoon practice.
Adrian Sutil, who complained about a problem with his Sauber over the radio, was the fastest of those who failed to escape Q1.
He was bumped down to 17th in the dying seconds of the first segment of qualifying by Button, who put on the quicker medium Pirelli in order to ensure he was not knocked out.
Max Chilton was 18th, outqualifying Marussia team-mate Jules Bianchi by six tenths of a second, with Marcus Ericsson doing a good job in the lead Caterham to end up just ahead of Kamui Kobayashi.
Pastor Maldonado will start last after failing to complete a flying lap before crashing.
He lost the rear end of his Lotus at the exit of Turn 3 after drifting wide on his first flying lap in Q1, spinning into the inside wall and bringing out the red flag for seven minutes.
Pos Driver Team/Car Time Gap 1. Lewis Hamilton Mercedes 1m25.232s 2. Nico Rosberg Mercedes 1m25.400s +0.168s 3. Daniel Ricciardo Red Bull-Renault 1m26.285s +1.053s 4. Valtteri Bottas Williams-Mercedes 1m26.632s +1.400s 5. Romain Grosjean Lotus-Renault 1m26.960s +1.728s 6. Kimi Raikkonen Ferrari 1m27.104s +1.872s 7. Fernando Alonso Ferrari 1m27.140s +1.908s 8. Jenson Button McLaren-Mercedes 1m27.335s +2.103s 9. Felipe Massa Williams-Mercedes 1m27.402s +2.170s 10. Sebastian Vettel Red Bull-Renault Q3 cut-off time: 1m27.602s ** 11. Nico Hulkenberg Force India-Mercedes 1m27.685s +1.597s 12. Sergio Perez Force India-Mercedes 1m28.002s +1.914s 13. Daniil Kvyat Toro Rosso-Renault 1m28.039s +1.951s 14. Esteban Gutierrez Sauber-Ferrari 1m28.280s +2.192s 15. Kevin Magnussen McLaren-Mercedes 16. Jean-Eric Vergne Toro Rosso-Renault Q2 cut-off time: 1m28.472s * 17. Adrian Sutil Sauber-Ferrari 1m28.563s +1.799s 18. Max Chilton Marussia-Ferrari 1m29.586s +2.822s 19. Jules Bianchi Marussia-Ferrari 1m30.177s +3.413s 20. Marcus Ericsson Caterham-Renault 1m30.312s +3.548s 21. Kamui Kobayashi Caterham-Renault 1m30.375s +3.611s 22. Pastor Maldonado Lotus-Renault 107 per cent time: 1m32.837s * Gap to fastest in Q1 ** Gap to fastest in Q2