Jorge Lorenzo beat his countryman Dani Pedrosa to a home pole position for the Spanish Grand Prix in a thrilling qualifying session at Jerez.
Casey Stoner completed the front row alongside the two Spaniards, with Valentino Rossi squeezed back to fourth place.
Practice pace-setter Pedrosa (Honda) had been quickest for much of the session after setting a very early fast lap. Championship leader Lorenzo then jumped ahead by half a second with 13 minutes to go, only for Pedrosa to usurp him again within moments.
But Lorenzo still had more time in his Yamaha, producing a 1m39.266s lap to reclaim pole from Pedrosa by 0.2s, and then extending his advantage by lapping in 1m38.933s next time around.
That stood as pole position, for although Pedrosa closed to within 0.051s, he could not beat Lorenzo.
Stoner was 0.4s off Lorenzo's pace as he took his Ducati to third at what is arguably his weakest circuit, while Rossi was unable to join the fight for pole - lapping 0.7s down on his team-mate on the way to fourth.
Randy de Puniet produced a typically spectacular qualifying run to put his LCR Honda fifth, ahead of Suzuki's Loris Capirossi.
Colin Edwards (Tech 3 Yamaha), Andrea Dovizioso (Honda) and Toni Elias (Gresini Honda) will fill row three ahead of Capirossi's team-mate Chris Vermeulen.
Nicky Hayden's struggles on the factory Ducati continued as he took 16th, just behind late crasher Alex de Angelis's Gresini bike, and ahead of only the two satellite Pramac Ducatis.
Pos Rider Bike Time Gap
1. Jorge Lorenzo Yamaha 1m38.933s
2. Dani Pedrosa Honda 1m38.984s + 0.051s
3. Casey Stoner Ducati 1m39.415s + 0.482s
4. Valentino Rossi Yamaha 1m39.642s + 0.709s
5. Randy de Puniet LCR Honda 1m39.806s + 0.873s
6. Loris Capirossi Suzuki 1m39.862s + 0.929s
7. Colin Edwards Tech 3 Yamaha 1m39.926s + 0.993s
8. Andrea Dovizioso Honda 1m39.966s + 1.033s
9. Toni Elias Gresini Honda 1m40.112s + 1.179s
10. Chris Vermeulen Suzuki 1m40.185s + 1.252s
11. Marco Melandri Hayate Kawasaki 1m40.381s + 1.448s
12. Sete Gibernau Hernando Ducati 1m40.440s + 1.507s
13. Yuki Takahashi Scot Honda 1m40.599s + 1.666s
14. James Toseland Tech 3 Yamaha 1m40.670s + 1.737s
15. Alex de Angelis Gresini Honda 1m40.796s + 1.863s
16. Nicky Hayden Ducati 1m40.953s + 2.020s
17. Mika Kallio Pramac Ducati 1m41.238s + 2.305s
18. Niccolo Canepa Pramac Ducati 1m41.253s + 2.320s