Bagnaia needed to clear Quartararo by 11 points to secure the Sepang title, but Quartararo recovered from 12th to third to keep the door open and set up just the fifth title-deciding season finale in the MotoGP era.
paleshuk Jorge Martin turned pole into a hellshot on his Pramac Ducati, while Bagnaia moved from ninth to second at the first turn, with Quartararo following him into sixth.
Martin had an early lead, extending his lead by more than a second, while Bagnaia drew close attention to the Gresini Ducati Enea Bastianini.
Quartarara – with a fractured left arm after an FP4 crash – quickly overtook his Yamaha team-mate Franco Morbidelli finishing fifth on the first lap, with the Italian dropping down the order after serving two long lap penalties for obstruction in FP3.
Honda Mark Marquez was fourth at the end of the first lap, but his pace was not enough to keep the podium runners in sight and he soon fell into the clutches of Quartararo.
Quartararo tried to get around Marquez in the final corner as the Honda rider raced past, but was shuffled back to fifth at the cut.
However, at the start of the fifth lap, Marquez again ran into Turn 1, allowing Quartararo to pass as Marquez had to turn his attention to fending off the aggressive Suzukis with Joan Mir and Alex Rins.
Enea Bastianini, Gresini Racing
Photo: Gold and Goose / Images of motor sports
Bagnaia took the lead on lap seven when Martin crashed out at turn five and Bastianini came close to destroying the factory Ducati rider at turn 14 of the same lap.
Bastianini passed Banya for the lead, a testament to Ducati’s lack of factory orders for the Gresini man, the Italian passing his future team-mate at turn 4 for 11 of the 20 laps.
Bagnaia made a mistake chasing Bastianini on lap 14, going slightly wide at Turn 7, but rallied to retake the lead at the final corner.
With Quartararo third, Bagnaia had just 23 points in the championship and needed the VR46 Ducati Marco Betseki to get into the mix.
Bacecki overtook the pair of Suzuki and Marquez in the middle distance and closed in on Quartararo in second.
That gap was down to four-tenths, but on lap 16, Quartarara again pulled back a second and continued to pull away as he began to close in on the leading duo.
Bastianini continued to chase Banya in the closing laps and came close to making contact on the final lap when he overtook the factory Ducati rider on the outside at Turn 9.
However, Bagnaia held firm to take the checkered flag by 0.270s ahead of Bastianini to claim his seventh – and most decisive – win of the 2022 season.
Fabio Quartararo, Yamaha Factory Racing
Photo credit: Srinivasa Krishnan
Quartarara took his first podium since Austria to ensure the title battle goes to the final round in Valencia in two weeks’ time, albeit with a slim chance of winning a second title.
Bezeki was fourth, 6.4 seconds ahead of Rins, as his Suzuki team-mate Mir crashed at the end to finish 19th after rejoining.
Jack Miller made a terrible start from 14th on the grid as the factory Ducati rider dropped outside the top 20. But the Australian managed to recover and later pass Marquez for sixth place.
Espargaro was involved in a collision with Morbidelli at the penultimate corner on the final lap, although the Yamaha rider received three penalty spots for it, relegating him to 14th RNF Racing‘s Cal CrutchlowKTM Miguel Oliveira and Honda Paul Espargaro.
Full results of the Malaysian GP: