Valentino Rossi scored his first MotoGP pole position since 2016 at the end of a scintillating qualifying session at Mugello, beating Jorge Lorenzo by less than half a tenth.
Marc Marquez's record lap of 1m46.439s, established earlier in the day during third practice, was beaten by the leading four riders in a frantic end to the second phase of qualifying.
Suzuki rider Andrea Iannone was first to dip beneath Marquez's benchmark with eight minutes to go, reclaiming the record he previously set on a Ducati in 2015 with a 1m46.347s.
That stood as the best time until Rossi pumped in a 1m46.208s with two minutes left on the clock.
Marquez looked as if he might be able to overhaul his old rival on his final flying lap, having been a tenth up at the second split, but the Honda rider lost time thereafter and had to save a crash at Bucine.
That left Rossi with the 55th pole position of his premier class career by a margin of 0.035s over Lorenzo's Ducati, his first since the 2016 Japanese Grand Prix at Motegi.
Maverick Vinales was third on the second factory Yamaha, having progressed from Q1, while Marquez had to be content with sixth place behind Iannone and the lead Pramac bike of Danilo Petrucci.
Andrea Dovizioso leads the third row on the second factory Ducati ahead of Cal Crutchlow's LCR Honda and Johann Zarco aboard the Tech 3 Yamaha, while Alex Rins' Suzuki completes the top 10.
Q1 pacesetter Jack Miller could do no better than 11th ahead of Franco Morbidelli, who made his first ever Q2 appearance on his Marc VDS Honda after qualifying directly by dint of his practice time.
Earlier, the bulk of the opening qualifying session was led by Vinales and Tito Rabat's Avintia Ducati, who rode in tandem to lock out the two Q2 spots heading into the final minutes.
But with three minutes to go, Miller managed to eclipse Vinales' effort by 0.035s with a 1m46.771s, demoting the Yamaha man to second and Rabat to third.
Rabat, still following Vinales, looked set to get his place in Q2 back on the final runs, but Vinales backed out of his final flying lap and Rabat fell short by 0.102s without the benefit of the Yamaha's tow.
It means Rabat starts 13th, ahead of Tech 3's Hafizh Syahrin and the lead KTM of Pol Espargaro.
Dani Pedrosa could only manage the 10th fastest time in Q1, 1.294s off the pace of Miller, making him the slowest of all six Honda riders - behind Takaaki Nakagami (18th) and Thomas Luthi (19th).
It means Pedrosa (below) will start 20th, which is his worst-ever MotoGP qualifying position.
Enduring a similarly wretched session was Aprilia, with Aleix Espargaro only managing 21st after a Q4 crash and Scott Redding ending up 23rd on the second RS-GP.
|5||Danilo Petrucci||Pramac Ducati||1m46.445s||0.237s|
|8||Cal Crutchlow||LCR Honda||1m46.813s||0.605s|
|9||Johann Zarco||Tech3 Yamaha||1m46.830s||0.622s|
|11||Jack Miller||Pramac Ducati||1m46.998s||0.790s|
|12||Franco Morbidelli||MVDS Honda||1m47.002s||0.794s|
|13||Tito Rabat||Avintia Ducati||1m46.908s||0.700s|
|14||Hafizh Syahrin||Tech3 Yamaha||1m47.188s||0.980s|
|16||Alvaro Bautista||Aspar Ducati||1m47.708s||1.500s|
|18||Takaaki Nakagami||LCR Honda||1m47.868s||1.660s|
|19||Thomas Luthi||MVDS Honda||1m47.989s||1.781s|
|22||Karel Abraham||Aspar Ducati||1m48.532s||2.324s|
|24||Xavier Simeon||Avintia Ducati||1m48.794s||2.586s|