Maverick Vinales claimed his second successive pole position at Misano as an error from Francesco Bagnaia saw him miss out on the front row in a dramatic qualifying session for the Emilia Romagna and Rimini's Coast Grand Prix.
Bagnaia, who smashed the Misano lap record in third practice, found searing pace as the Pramac Racing rider attempted to deny Vinales.
He crossed the line in one minute and 30.973 seconds, which would have seen him take a first career pole and set the first 1:30 lap at the Marco Simoncelli circuit.
However, his lap was immediately expunged as Bagnaia exceeded the track limits on the final turn, handing pole to Vinales after his lap record of 1:31.077.
Bagnaia dropped to fifth, with Jack Miller and Fabio Quartararo completing the front row behind Vinales.
The KTMs of Pol Espargaro and Brad Binder were fourth and sixth respectively, while championship leader Andrea Dovizioso will have work to do to hold on to his six-point lead over Quartararo.
Dovizioso was 10th behind Ducati team-mate Danilo Petrucci, the fourth row completed by Joan Mir and Takaaki Nakagami.
LCR Honda's Nakagami went off at turn 15 in FP4 and repeated that error in Q2, wrecking his second bike of the race week and leaving him to settle for 12th on the grid.
1. Maverick Vinales (Monster Energy Yamaha) 1:31.077s
2. Jack Miller (Pramac Racing) +0.076s
3. Fabio Quartararo (Petronas Yamaha) +0.145s
4. Pol Espargaro (Red Bull KTM Factory Racing) +0.231s
5. Francesco Bagnaia (Pramac Racing) +0.236s
6. Brad Binder (Red Bull KTM Factory Racing) +0.312s
7. Valentino Rossi (Monster Energy Yamaha) +0.359s
8. Franco Morbidelli (Petronas Yamaha) +0.489s
9. Danilo Petrucci (Ducati) +0.497s
10. Andrea Dovizioso (Ducati) +0.504s
11. Joan Mir (Suzuki Ecstar) +0.540s
12. Takaaki Nakagami (LCR Honda) +1.207s