Jorge Lorenzo claimed his first MotoGP pole position for Ducati in qualifying for the Catalan Grand Prix in Barcelona.
Lorenzo, who had recorded his first win with Ducati last time out at Mugello, beat the resurgent Marc Marquez by 0.066s late on in the Q2 decider.
Marquez had been consigned to his second-ever Q1 appearance in MotoGP by a late crash in third practice, but made short work of advancing to the pole shoot-out.
He ended his first run in the opening segment with a comfortable lead, and gradually improved his time with several successive laps late on, never threatened by any of the other Q1 riders.
As Q2 kicked off, Lorenzo took the initial lead, only for Marquez to fire in a 1m38.886s – the best lap of the weekend at that point, completed in tow behind Tech 3 Yamaha's Johann Zarco – which left the reigning champion almost four tenths clear after the opening runs.
Dovizioso improved to within 0.037s of pole as the final runs kicked off, only for Marquez to respond immediately, recording a 1m38.746s.
But Lorenzo, who appeared to rage at his crew after coming into the pits for his bike swap, was even faster, finding time on Marquez in the final sector and securing pole position with a 1m38.680s.
Lorenzo still had time for a final flying lap, but did not make gains, which left him vulnerable to last-gasp efforts from Dovizioso and Marquez.
Dovizioso had been up on Lorenzo two sectors in after the chequered flag, but came up on Yamaha's Maverick Vinales and couldn't improve.
The same fate befell Marquez, who was only a tenth short heading into the final sector before coming up on Pramac's Danilo Petrucci.
With Marquez and Dovizioso completing the front row, Vinales was the top Yamaha in fourth, just 0.003s clear of Suzuki's Andrea Iannone – whose works teammate Alex Rins will start only 15th.
Petrucci, who stopped alongside Marquez after the chequered flag to apologise, made up the second row, ahead of Valentino Rossi, who was forced to roll out of his final effort after a huge moment.
Zarco took eighth, with Avintia Ducati's Tito Rabat ninth and Cal Crutchlow only 10th, his qualifying compromised by a late crash at the high-speed Turn 13 right-hander.
Marquez's Honda teammate Dani Pedrosa was 11th, ahead of LCR Honda rookie Takaaki Nakagami – the Japanese rider making his first Q2 appearance after denying Pramac Ducati's Jack Miller in the fight for second in Q1.