Valentino Rossi blew his first chance of a MotoGP victory since June 2017 when he threw away the lead at the Malaysian round of the championship on Sunday at Sepang.
The Movistar Yamaha rider was ahead of world champion Marc Marquez when he slid off on lap 17.
It was a bitter blow for the nine-time world champion, whose last premier class triumph for Yamaha came at Assen last year.
Rossi was able to rejoin the race, crossing the line in 18th place as Marquez went on to secure victory on the Repsol Honda over Alex Rins on the Ecstar Suzuki, with Frenchman Johann Zarco filling the top three on the Tech 3 Yamaha.
A dejected Rossi, who also lost the chance to take over second place in the world championship standings from Ducati’s Andrea Dovizioso, said his misfortune was ‘a great shame’.
“It was a great shame because this was my best race of the season. I felt comfortable, I had a good pace, I pushed, and I had the chance to win, but unfortunately with four or five laps to go I fell - I don't understand what happened,” Rossi said.
“I made a mistake, because I crashed. It's such a pity, but it still remains a good weekend, because we improved the setting of the bike. I think we have to do some more work, but it looks like we were able to use the bike in a better way in the last few races.
“This is good, but we have to see if we're also strong in Valencia. It's a difficult track for us in general, but we have to try.”
Rossi’s team-mate and Phillip Island winner Maverick Vinales battled through to claim fourth ahead of Dani Pedrosa (Repsol Honda), who will compete in his final MotoGP race at the last round of the 2018 championship at Valencia in Spain (November 16-18).
Spaniard Vinales' victory at Phillip Island in Australia at the previous round was Yamaha's first MotoGP win since Rossi scaled the top step at Assen in 2017.
Andrea Dovizioso, who had won the last two races at Sepang, finalised the top six places on the factory Ducati.