Lewis Hamilton will start from pole position in Sunday's Spanish Grand Prix after edging out Mercedes team-mate Valtteri Bottas by just four hundredths of a second.
Hamilton, who holds a four-point championship lead over Sebastian Vettel, delivered a record-breaking lap of Barcelona's Circuit de Catalunya to claim his first pole since the opening round in Australia.
Vettel has been the one-lap master this year following a hat-trick of poles, but the Ferrari man had no answer for an inspired Hamilton here on Saturday. Vettel will line up in third after qualifying 0.132 seconds slower than Hamilton.
Kimi Raikkonen finished in fourth place for Ferrari, ahead of the Red Bull duo of Max Verstappen and Daniel Ricciardo.
"It was very close but I am very happy," Hamilton said. "I needed this pole because I haven't had one for a while."
Vettel added: "I was happy with the lap. The first run was not so good, but the last lap felt good. Then I looked where I ended up and I saw that my name didn't go to the top. We expected Mercedes to be strong."
McLaren arrived for the opening leg of the European season armed with a series of upgrades and hopeful of turning a corner following their miserable start to the season.
On the fifth anniversary of his last victory in F1, Fernando Alonso ensured a McLaren car progressed to the final phase of qualifying for the first time this year.
The 36-year-old Spaniard will line up in eighth place with his team-mate Stoffel Vandoorne 11th. Progress perhaps, but there is still work to do for the team who claimed they would rival Red Bull this year following their switch from Honda to Renault power.
British team Williams could once boast the might of Nigel Mansell, Alain Prost and Nelson Piquet, who between them shared nine world championships.
But their current line-up of Lance Stroll, the Canadian teenager whose career has been bankrolled by his fashion billionaire father Lawrence, and Russian Sergey Sirotkin, is possibly the worst in the team's history.
Their car is desperately poor this year, too, and they will head into tomorrow's race rooted to the foot of the constructors' championship.
It seems certain they will remain there after Stroll crashed out of qualifying, while Sirotkin was only one place ahead of him. Stroll stepped on to the gravel at Turn 12 and spun into the barriers to bring a premature end to his session.
It marked the third time he has been in the gravel this weekend. "I've never seen a Formula One car crash like that on the exit of Turn 12," Sky Sports pundit Martin Brundle said in bemusement.
Williams will be spared the indignity of seeing both of their cars on the final row of the grid after Brendon Hartley suffered a 160mph crash in final practice.
New Zealander Hartley, 28, was taken to the medical centre for precautionary checks but despite being given the green light to continue his Toro Rosso team were unable to get his severely damaged car ready in time for qualifying.