Lewis Hamilton bounced back from the disappointment of Russia to beat championship leader Sebastian Vettel and claim his third pole position of 2017 for the Spanish GP.
In a closely-fought qualifying hour between Mercedes and Ferrari, Hamilton headed all three sessions and then held on to top spot as Vettel came on strong on the final Q3 runs.
Sky F1's Spanish GP Race Day schedule
Although Hamilton did not improve his benchmark 1:19.149 on his final run, a costly lock-up at the final chicane meant Vettel came up 0.051s short as he crossed the line. But the German did deny Mercedes a front-row lock-out as Valtteri Bottas was relegated to third.
Vettel and Bottas had endured disrupted build-ups to qualifying due to unplanned engine changes on their respective cars, with both drivers now running older engines compared to their team-mates.
Meanwhile, Fernando Alonso delivered the biggest shock of qualifying by overcoming McLaren's acknowledged big Honda power deficit to claim a stunning seventh on the grid for his home race.
Kimi Raikkonen was fourth ahead of the Red Bulls, who clearly remain as 2017's third-fastest team despite the RB13's extensive Barcelona upgrade. But Max Verstappen, who has been the quicker Red Bull driver all weekend, was only half a second adrift of pole in fifth - the team's smallest Saturday deficit to the front so far this season.
Hamilton back on form - and back on pole
Mercedes had said there were "no magic bullets" for getting to the bottom of the tyre temperature problems which afflicted Hamilton in Sochi, but the triple champion has shown few signs of fallibility on the familar ground of the Circuit de Catalunya so far this weekend.
Hamilton had outpaced team-mate Bottas in every session before qualifying and, with his team-mate on the back foot following an overnight engine change for a water leak, the Briton carried that advantage into Saturday's grid-setting session.
"Amazing job by the team and super proud we can get back up there and have a better weekend," said Hamilton after claiming his 64th F1 pole, one fewer than his hero Ayrton Senna and four adrift of Michael Schumacher's all-time record.
"The first lap of Q3 was really good, the second was so-so."
That "so-so" final lap nearly opened the door for Vettel, who was up on Hamilton's provisional time through the first two sectors of his final lap before his hopes of a first-ever Barcelona pole were scuppered at the final chicane.
"A tiny lockup was the difference," said Vettel. "I've been coming here so many times and still the last chicane is tricky for me. It was really close."
At one point it had looked as though Vettel, whose engine was changed on precautionary grounds after practice, would not even get that far after he was told to "stop the car" at the start of Q1. However, he continued and was able to resolve the problem from in-car without returning to the pits.
And with neither of his two wins so far in 2017 coming from the very front of the grid, the Ferrari driver remains optimistic of stretching his 13-point championship advantage on Sunday.
"I just need to do everything right at the start that is the best way to attack and defend," added the four-time world champion. "In terms of performance, it is very close. It will be close - we could have been ahead today, and that was down to me. I am confident for tomorrow."
Alonso serves up qualifying surprise
For the just the second time since his return to McLaren in 2015, Alonso will start inside the front four rows after the Spaniard produced what Sky F1's Martin Brundle described as "the lap of the weekend" to first make Q3 for the first time this season and then beat his midfield rivals to the 'best of the rest' slot behind the top three teams.
Is keeping Alonso mission impossible?
Even a top-10 position had looked a long way from reality after Alonso's MCL32, which has failed to finish a race this year, broke down within three corners of its installation lap in Friday practice.
That latest breakdown had prompted Alonso to leave the track to play tennis back at his hotel, but he reckons the Honda-powered car had the potential for such an eye-catching result.
"I was preparing myself yesterday for qualifying," he joked. "Everything today went perfectly. It's a nice surprise. We say the potential yesterday and today we put everything together.
"I'm happy for the team, they changed many power units and to now be P7 and feel tomorrow on the grid around the cars we should be fighting for will be really nice."
Alonso's achievement was put into starker light by team-mate Stoffel Vandoorne's fifth successive Q1 exit, with the Belgian yet to clear the first qualifying hurdle since the start of his rookie season.
The Belgian was one of a number of drivers left to reflect on sizebale deficits to their team-mates with Jolyon Palmer, Lance Stroll and Daniil Kvyat all also falling a long way short of their sister cars and failing to clear the first hurdle.
Spanish GP Qualifying results
Q3
1. Lewis Hamilton, Mercedes, 1:19.149
2. Sebastian Vettel, Ferrari, +0.051
3. Valtteri Bottas, Mercedes, +0.224
4. Kimi Raikkonen, Ferrari, +0.290
5. Max Verstappen, Red Bull, +0.557
6. Daniel Ricciardo, Red Bull, +1.026
7. Fernando Alonso, McLaren, +1.899
8. Sergio Perez, Force India, +1.921
9. Felipe Massa, Williams, +2.093
10. Esteban Ocon, Force India, +2.123
Knocked out in Q2
11. Kevin Magnussen, Haas, 1:21.329
12. Carlos Sainz, Toro Rosso, 1:21.371
13. Nico Hulkenberg, Renault, 1:21.397
14. Romain Grosjean, Haas, 1:21.517
15. Pascal Wehrlein, Sauber. 1:21.803
Knocked out in Q1
16. Marcus Ericsson, Sauber, 1:22.332
17. Jolyon Palmer, Renault, 1:22.401
18. Lance Stroll, Williams, 1:22.411
19. Stoffel Vandoorne, McLaren, 1:22.532
20. Daniil Kvyat, Toro Rosso, 1:22.746
Don't miss the Spanish GP exclusively live on Sky Sports F1 on Sunday - lights out for the race is at 1pm. Check out all the ways to watch F1 on Sky Sports for subscribers and non-subscribers - including a NOW TV day pass for £6.99!
Have your say! Comment below to get involved in the debate, but please adhere to our House Rules. If you wish to report any comment, simply click on the down arrow next to the offending comment and click 'Report'.