Lewis Hamilton has sealed what could turn out to be a crucial pole position for the Spanish Grand Prix after edging out championship rival Sebastian Vettel.
Hamilton, who secured the 64th pole of his career to move to within one of his boyhood hero Ayrton Senna, finished just 0.051 seconds ahead of Vettel following a frenetic qualifying session at Barcelona's Circuit de Catalunya.
Valtteri Bottas lines up in third for Mercedes with Ferrari driver Kimi Raikkonen fourth on the grid.
Hamilton, fastest in both Q1 and Q2, appeared on course to seal an easy pole only for Vettel to provide a late charge in the closing moments of the session.
Indeed the four-time champion, who leads Mercedes driver Hamilton in the championship race by 13 points, was marginally quicker than the Briton throughout his final timed run - only to lock a brake in the closing stages and finish second to his rival.
There had been early drama for the 29-year-old German in Q1 - the opening phase of qualifying - after he was told to stop on the track following an apparent fault within his Ferrari car.
But Vettel queried the decision. "Are you sure," Vettel said. He was urged to get his car back to the pit lane, but the problem suddenly cleared up and Vettel soared to the top of the timesheets rather than fall at the first hurdle of qualifying.
Fernando Alonso missed the entirety of first practice on Friday after his Honda engine blew up just three corners into his very first lap. But incredibly the 35-year-old Spaniard dragged his McLaren not only into the final phase of qualifying, but then to seventh on the grid for tomorrow's grand prix in front of his home fans.
It marked the first time a McLaren car has progressed to the top-10 shootout this season and there were high-fives in the team garage which included Mansour Ojjeh, who owns a 25 per cent stake in the British outfit.
British driver Jolyon Palmer is desperately in need of a strong weekend here after his difficult start to the new season, but the 26-year-old Englishman failed to make his way out of Q1 and will line up only 17th on the grid.
Palmer's Renault team-mate Nico Hulkenberg has finished in the points at the last two races and comfortably out-qualified him again here. He will start 13th tomorrow.
"I don't know what happened," a bemused Palmer told Sky Sports. "The pace has gone. I was happy yesterday and jumped straight in and feeling good. Today it's just gone.
"I'm quite confused. I didn't do such a horrendous lap but it just wasn't there. We'll work on it. Somewhere in the data there will be an explanation."
Max Verstappen, a winner in Spain last year, qualified fifth ahead of his Red Bull team-mate Daniel Ricciardo.
Hamilton started on pole a year ago but he collided with his former Mercedes team-mate Nico Rosberg on the opening lap.
"It's going to be a tough race tomorrow that's for sure," Hamilton, 32, said. "It is all milliseconds between us.
"It's the third longest run down to turn one so it's going to be important to get a good start. I'm just going to do the best job I can."
Vettel, whose Ferrari team were forced to change his engine on Saturday morning, added: "The team did a phenomenal job.
"We had an issue this morning and we had to change the engine. Normally that's a three-hour job but they did it in under two hours. A big thank you to them.
"Kimi's crew helped out. It was quite funny. One side of the garage had one or two mechanics and the other side was completely crowded, like bees hovering around the car.
"I think we could have had pole today. Not the ideal end, but if I think about where we were this morning it was a really good recovery."