Dani Pedrosa kept his cool on a day of stumbles to secure pole position for the Catalan Grand Prix.
Marc Marquez had looked the man to beat after dominating Friday practice but the reigning world champion will head up the second row after he was unseated four times in Q2.
It paved the way for his Repsol Honda team-mate to take advantage and Pedrosa's top time of one minute 43.870 seconds was three tenths quicker than Jorge Lorenzo, who will start second.
Joining the Spanish pair on the front row is Danilo Petrucci, who followed up his surprise podium in Mugello last time out with a barnstorming qualifying run, losing out to Lorenzo by just two hundredths.
Championship leader Maverick Vinales will start ninth after a day of struggles for Yamaha machines. Jonas Folger was the highest-placed rider with Yamaha power, in eighth.
Valentino Rossi was the highest-profile casualty of Q1 and will start Sunday's race in 13th.
1. Dani Pedrosa (Repsol Honda) 1:43.870
2. Jorge Lorenzo (Ducati) 1:44.201
3. Danilo Petrucci (Pramac) 1:44.220
4. Marc Marquez (Repsol Honda) 1:44.320
5. Aleix Eespargaro (Aprilia) 1:44.348
6. Hector Barbera (Avintia Racing) 1:44.381
7. Andrea Dovizioso (Ducati) 1:44.451
8. Jonas Folger (Monster Yamaha Tech 3) 1:44.600
9. Maverick Vinales (Movistar Yamaha) 1:44.620
10. Alvaro Bautista (Aspar Team) 1:44.740