Fabio Quartararo smashed his own Jerez lap record to claim the first MotoGP pole of 2020 in a dramatic Spanish Grand Prix qualifying.
FP3 pacesetter Quartararo set the early time to beat with a 1m37.064s, which was immediately beaten by Marquez with a 1m37.006s.
The Petronas SRT rider dipped underneath the 1m37s barrier on his second flying lap to reclaim provisional pole with a 1m36.993s, while Pramac's Francesco Bagnaia put his Ducati into third despite encountering a slower Valentino Rossi at the last corner.
Marquez returned to top spot with a 1m36.877s on his first lap of his second run, though this was beaten by Maverick Vinales, who put in a blinding final sector to end up with a 1m36.844s.
With around a minute to go, Pramac's Jack Miller was on a lap challenging for pole, but suffered a fast crash at Turn 11.
Just seconds later, Alex Rins crashed at the same place and had to be helped into the back of an ambulance as he held his wrist.
Amidst the drama, Quartararo produced a 1m36.705s to dip underneath the lap record he set in FP3 and secure his second-successive Jerez pole.
Vinales held onto second, with Marquez rounding out the front row ahead of Bagnaia - whose fourth-place is a career-best qualifying result.
Miller will start alongside his team-mate in fifth place despite his crash, with LCR's Cal Crutchlow just 0.001s behind him in sixth.
Pol Espargaro came through Q1 alongside Rins - who also crashed in the first session - and put his KTM seventh ahead of the factory Ducati of Andrea Dovizioso, who fell off at Turn 2 late on.
Rins was ninth, though his start now looks in doubt, with Franco Morbidelli (SRT), Rossi and Joan Mir (Suzuki) completing the top 12.
Brad Binder was briefly held the fastest time in Q1, and ultimately qualified an impressive 13th for his MotoGP debut on the KTM having only missed a place in Q2 by just 0.138s.
The 2016 Moto3 world champion beat the works Ducati of Danilo Petrucci, with Takaaki Nakagami slotting into 15th on his year-old LCR Honda.
Aleix Espargaro was top Aprilia in 16th, while team-mate Bradley Smith was 18th after suffering a highside crash at Turn 2 in the closing stages.
Johann Zarco also suffered a tumble late on, which stopped the Avintia Ducati rider advancing on his 20th position ahead of Honda rookie Alex Marquez and the Tech3 KTM of Iker Lecuona.
Spanish GP qualifying results:
|1||Fabio Quartararo||Petronas Yamaha||1m36.705s|
|4||Francesco Bagnaia||Pramac Ducati||0.250s|
|5||Jack Miller||Pramac Ducati||0.748s|
|8||Franco Morbidelli||Petronas Yamaha||0.969s|
|13||Takaaki Nakagami||LCR Honda||0.729s|
|15||Miguel Oliveira||Tech3 KTM||1.259s|
|17||Tito Rabat||Avintia Ducati||1.324s|
|18||Johann Zarco||Avintia Ducati||1.401s|
|20||Iker Lecuona||Tech3 KTM||1.807s|
|1001||Cal Crutchlow||LCR Honda||0.749s|