Championship leader Marc Marquez won MotoGP's San Marino Grand Prix, after seeing off rookie Fabio Quartararo in a breathless last-lap battle.
Quartararo led each of he first 26 laps but was denied a maiden win by Marquez, who had to pass the Petronas Yamaha rider twice on the final lap.
Poleman Maverick Vinales maintained the lead off the line, as Petronas duo Quartararo and Franco Morbidelli briefly made it a Yamaha 1-2-3.
Marquez, who had started fifth after his qualifying run-in with Valentino Rossi, improved to fourth on the opening lap and picked off Morbidelli at Turn 8 on the second tour to set after the leaders.
As the championship leader kept Vinales and Quartararo in his sights, Quartararo got a superb run on his factory Yamaha rival out of Turn 10 and edged ahead entering Curvone to take the lead and immediately begin breaking away.
By the time Marquez pulled off an aggressive move on Vinales down the inside of Turn 10 on the following lap, Quartararo was already almost a second up the road - but the Honda man needed just a couple of laps to arrive right behind the rookie.
Yet Quartararo held firm in the lead, the gap between him and Marquez fluctuating between one and four tenths for a long stretch of the race as Quartararo soaked up the pressure.
Marquez, however, ramped up his efforts as the race entered its final three laps, and finally drew alongside Quartararo at the end of the penultimate lap to take the lead into Turn 1.
Quartararo responded with a brave dive down the inside at Turn 4, but Marquez outdragged the Yamaha on the run up to Quercia, then braked late to consolidate the lead.
And while Quartararo kept Marquez in his sights through the next few corners, he had to release the throttle to avoid clattering into the Honda at Turn 14, and was forced to settle for second place.
The victory leaves Marquez with a 93-point lead in the championship, with 150 up for grabs in the remaining six races.
Vinales had slipped to two seconds behind the leading duo after losing first place, and while he kept pace with the pair from then on, he could only close the gap to the race winner down to 1.6s by the finish.
His fellow works rider Valentino Rossi and Morbidelli made it four Yamahas in the top five.
Having cleared the KTM of Pol Espargaro, Rossi spent several laps behind Morbidelli before lunging down the inside of his protege at Quercia.
Though he ran out wide to allow Morbidelli back through, he then got the move done at Turn 14, going on to finish a tenth clear.
Andrea Dovizioso salvaged sixth place in a difficult race for Ducati, while Espargaro - who had started on the front row - was shuffled down to seventh.
Suzuki's Joan Mir, making his return from injury, was eighth ahead of the Pramac Ducati of Jack Miller and the second works Ducati of Danilo Petrucci.
Aleix Espargaro finished 12th as the sole Aprilia, with Andrea Iannone absent through injury, while Marquez's Honda team-mate Jorge Lorenzo took 14th.
Suzuki rider Alex Rins ran sixth in the early going, but his progress was stalled when he straightlined Turn 2 in pursuit of Espargaro.
Back on Espargaro's tail, he overtook the KTM rider, only to immediately receive a long-lap penalty and then crash at Turn 4 before he could serve it.
Francesco Bagnaia (Pramac) and Miguel Oliveira (Tech3) also crashed at Turn 4, while LCR duo Takaaki Nakagami and Cal Crutchlow, and Ducati tester Michele Pirro, were also among the fallers. Pirro was 10th, ahead of Petrucci, when he hit the deck.
Result - 27 laps
|2||Fabio Quartararo||Petronas Yamaha||Yamaha||0.903s|
|5||Franco Morbidelli||Petronas Yamaha||Yamaha||12.774s|
|9||Jack Miller||Pramac Ducati||Ducati||26.554s|
|13||Tito Rabat||Avintia Ducati||Ducati||35.325s|
|15||Hafizh Syahrin||Tech3 KTM||KTM||1m02.280s|
|16||Miguel Oliveira||Tech3 KTM||KTM||1m07.831s|
|17||Karel Abraham||Avintia Ducati||Ducati||1m24.666s|
|18||Takaaki Nakagami||LCR Honda||Honda||1 Lap|
|-||Cal Crutchlow||LCR Honda||Honda||Retirement|
|-||Francesco Bagnaia||Pramac Ducati||Ducati||Retirement|