Bagnaia dominates to win wet Thai MotoGP ahead of title rival Martin
Martin's lead over defending champion Bagnaia of Italy was cut from 22 points to 17, ahead of another chapter in their title tussle at Sepang in Malaysia next week.
Pedro Acosta was third at Buriram.
Pramac Ducati's Martin began the race on the front row in third and made a lightning start to grab the lead from his pole-sitting rival.
But the 26-year-old did not stay there long, running wide to fall to third as Bagnaia took the lead with six-time MotoGP world champion Marc Marquez in hot pursuit.
At the halfway point of the 26-lap race, it had developed into a duel between Bagnaia and Marquez, with Martin struggling to keep up.
But Marquez pushed too hard in trying to take the lead and slid off on his Ducati.
That left the title rivals to battle it out for victory, but Bagnaia held his nerve and handled the demanding conditions to see out a crucial ninth win of the campaign.
Bagnaia also started Saturday's sprint race on pole but ended up third, just behind Martin. Bagnaia's Ducati teammate Enea Bastianini won the sprint.
After Malaysia, the season finale is at Valencia on November 15th-17th.
Earlier, Japan's Ai Ogura was crowned Moto2 world champion as he came second in a red-flagged race won by Spain's Aron Canet.
The 23-year-old Ogura will move up to MotoGP next season.