MotoGP world champion Jorge Lorenzo won the Italian Grand Prix after passing fellow Spaniard Marc Marquez in the final metres with a last-corner surge.
The Yamaha rider took the chequered flag by a mere 0.019 of a second just as Honda's Marquez appeared to have won a wheel-to-wheel duel between the two at the Mugello circuit near Florence.
Italian great Valentino Rossi, Lorenzo's team mate, started from pole position but dismayed his army of home fans when he retired with an engine failure and smoke billowing out of his bike on lap eight.
Italian Andrea Iannone finished third for Ducati, also setting a MotoGP top speed record of 354.9kph.
Lorenzo, in his final season with Yamaha before replacing Iannone at Ducati, extended his championship lead over Marquez to 10 points. Rossi is third and 37 off the pace.
"When he passed me on the last lap, I thought maybe I have to save the points," said Lorenzo, who was second coming out of the final turn but used his bike's acceleration to good effect on the straight.
The pair had traded the lead four times on the lap, with Marquez appearing to make his final move stick, only for Lorenzo to surge back for his 43rd career MotoGP win and fifth at Mugello.
"I tried the inside, but Marquez closed the door very well, so the only chance was the straight. I thought 'Jorge, you've lost the race'.
"My bike was very fast, I was recovering metres quickly, so finally I won the race unexpectedly," added the Spaniard, who had started fifth but led after turn one with Rossi chasing behind.
Lorenzo had also suffered a failure in the warm-up, with a new engine fitted for the race.
Double world champion Marquez said Honda had been struggling all weekend for acceleration out of the final turn.
"I knew it would be very close," he said. "The main target was a podium, but when I saw Valentino had a problem, this is when I saw that I was able to follow Lorenzo at the limit. I thought: 'OK, I will try'."
The two Spaniards were the riders the home crowd least wanted to see atop the podium in Rossi's backyard, after clashes with the Italian last year, and some spectators began leaving before the end of the race.