Andrea Iannone claimed pole position for the Austrian Grand Prix after coming through a hotly contested qualifying session at the Red Bull Ring.
The Ducati rider saved his best until the dying seconds as he denied Valentino Rossi from scoring an unlikely pole position.
Ducati had dominated practice but the Italian marque faced a stern challenge from Yamaha, with Rossi and reigning world champion Jorge Lorenzo enjoying spells at the top of the timesheets.
However, Iannone ended up on top after posting a 1:23.142s effort to eclipse Rossi, who held provisional pole when the chequered flag flew.
Rossi was just 0.147s shy of Iannone while the sister factory Ducati of Andrea Dovizioso secured the final spot on the front row in third.
Dovizioso had set the pace early in the session before he was pipped to provisional pole by Lorenzo at the halfway point.
Lorenzo ended qualifying in fourth ahead of championship leader Marc Marquez, who guided his Honda to fifth just hours after dislocating his shoulder following a crash in Practice 3.
Marquez was taken to a nearby hospital for a precautionary check on the injury before he received medical clearance to compete in qualifying.
Suzuki's Maverick Vinales completed the second row while Cal Crutchlow (LCR Honda), Scott Redding (Pramac Ducati), Aleix Espargaro (Suzuki) and Hector Barbera (Avintia Ducati) rounded out the top 10.
Ireland's Eugene Laverty produced a career best qualifying performance in 11th after the Aspar Ducati rider topped Q1.
He will start ahead of Honda's Dani Pedrosa who struggled for pace in the session.
Australia's Jack Miller endured a difficult qualifying which was interrupted by a crash at Turn 4 in the early stages of Q1.
The Assen winner went on to claim 20th on the grid after jumping onto his spare Marc VDS Honda.
Sunday's Austrian Grand Prix is scheduled to begin at 2200 AEST.
In Moto2, Aussie Remy Gardner qualified 23rd fastest in qualifying.
Result: MotoGP Austrian Grand Prix Qualifying
|Marc VDS Honda
|Marc VDS Honda