Dani Pedrosa put an end to Honda team-mate Marc Marquez's run of MotoGP pole positions as he secured the top spot for the Catalunya Grand Prix at Barcelona.
Marquez, who had been on pole for the last six races, crashed in the final minutes of qualifying and will start from third.
Pedrosa secured his first pole of the year with a time of 1m40.985s, beating Yamaha rival Jorge Lorenzo by 0.115 seconds.
LCR Honda's Stefan Bradl will start from fourth ahead of Valentino Rossi's Yamaha.
Aleix Espargaro qualified in sixth and was the top Open rider once again. Andrea Dovizioso, Bradley Smith, Yonny Hernandez and Pol Espargaro completed the top 10.
Alvaro Bautista and Andrea Iannone reached Q2 from Q1 having missed the top-10 cut with their practice times. The Spaniard's grid-deciding session, however, was hampered by a crash and he will start from 12th.
Marquez threw down the gauntlet early on, moving to P1 with his first flying lap, over two tenths ahead of Pedrosa and over three ahead of Lorenzo.
The championship leader switched bikes for his second attempt, but saw team-mate Pedrosa steal first place with four minutes to go, as Marquez decided to abort his second run and return to the pits to switch to his #1 bike for his final run.
Lorenzo then took second place two minutes from the end, relegating Marquez to third.
As the Honda rider prepared for his final flyer, he lost control of his bike and crashed at Turn 1. He was uninjured but could not return to the track.
Ducati's Cal Crutchlow endured a disappointing day and was unable to make it into Q2, the Briton ending up in 13th position on the grid ahead of Gresini's Scott Redding and Michele Pirro on the third Ducati.
American Nicky Hayden qualified in 16th position ahead of his return to racing action after missing the previous race due to injury.
Pos Rider Team/Bike Time Gap 1. Dani Pedrosa Honda 1m40.985s 2. Jorge Lorenzo Yamaha 1m41.100s +0.115s 3. Marc Marquez Honda 1m41.135s +0.150s 4. Stefan Bradl LCR Honda 1m41.220s +0.235s 5. Valentino Rossi Yamaha 1m41.290s +0.305s 6. Aleix Espargaro Forward Yamaha 1m41.308s +0.323s 7. Andrea Dovizioso Ducati 1m41.337s +0.352s 8. Bradley Smith Tech 3 Yamaha 1m41.491s +0.506s 9. Yonny Hernandez Pramac Ducati 1m41.671s +0.686s 10. Pol Espargaro Tech 3 Yamaha 1m41.677s +0.692s 11. Andrea Iannone Pramac Ducati 1m41.751s +0.766s 12. Alvaro Bautista Gresini Honda 1m42.024s +1.039s 13. Cal Crutchlow Ducati 1m42.578s Q1 14. Scott Redding Gresini Honda 1m42.730s Q1 15. Michele Pirro Ducati 1m42.955s Q1 16. Nicky Hayden Aspar Honda 1m43.043s Q1 17. Colin Edwards Forward Yamaha 1m43.226s Q1 18. Karel Abraham Cardion Honda 1m43.360s Q1 19. Broc Parkes PBM Aprilia 1m43.530s Q1 20. Hiroshi Aoyama Aspar Honda 1m43.564s Q1 21. Michael Laverty PBM Aprilia 1m43.737s Q1 22. Hector Barbera Avintia FTR-Kawasaki 1m44.115s Q1 23. Mike di Meglio Avintia FTR-Kawasaki 1m45.012s Q1 24. Michel Fabrizio Ioda Aprilia 1m46.214s Q1