Francesco Bagnaia triumphed in a hard-fought Malaysian Grand Prix as Fabio Quartararo ensured the MotoGP world championship would go down to the wire by finishing third on Sunday.

Ducati rider Bagnaia, who only moved ahead of his Yamaha rival last week, needed to outscore Quartararo by 11 points to secure the riders' title.

But Frenchman Quartararo recovered from 12th on the grid to make sure the title would still be undecided heading into the final race of the season for only the fifth time in the MotoGP era.

Still, with a 23-point gap in the standings Bagnaia is in a mightily strong position heading to Valencia in a fortnight.

Bagnaia himself had to fight his way through the grid having started ninth and was involved in a taut tussle for the win with fellow Italian Enea Bastianini at the top of the pack.

The pair took advantage of original race leader Jorge Martin crashing out on the seventh lap, following a blistering pole on Saturday, and exchanged the lead multiple times throughout their close-fought battle.

Bagnaia was boosted by a sensational start that saw him split Martin and Bastianini to move immediately into second on the first corner.

From there, he looked in comfortable command and when Martin took a tumble the lead opened up in front of him.

Bastianini refused to go quietly on his heels, however, taking the lead on the 11th lap around Turn 4, only for Bagnaia to wrestle back control three laps later, where he held on for an emphatic finish.

Last week's race winner Alex Rins came home in fifth, while Mooney VR46's Marco Bezzecchi's fourth-place finish put a third Italian into the top four in Sepang.

TOP 10

1. Francesco Bagnaia (Ducati) 40:14:332
2. Enea Bastianini (Gresini) +0.270
3. Fabio Quartararo (Monster Energy Yamaha) +2.773
4. Marco Bezzecchi (Mooney VR46) +5.446
5. Alex Rins (Suzuki Ecstar) +11.923
6. Jack Miller (Ducati) +13.472
7. Marc Marquez (Repsol Honda) +14.304
8. Brad Binder (Red Bull KTM) +16.805
9. Johann Zarco (Pramac Racing) +18.358
10. Aleix Espargaro (Aprilia) +21.591

CHAMPIONSHIP STANDINGS

Riders

1. Francesco Bagnaia (Ducati) 258
2. Fabio Quartararo (Monster Energy Yamaha) 235
3. Aleix Espargaro (Aprilia) 212
4. Enea Bastianini (Gresini) 211
5. Jack Miller (Ducati) 189

Teams

1. Ducati 447
2. Aprilia Racing 334
3. Red Bull KTM 306
4. Pramac Racing 302
5. Monster Energy Yamaha 271