An incredible fourth was taken by one time race leader Hafizh Syahrin who had an amazing wild card ride in his home grand prix on his Petronas Raceline bike.
In just his second grand prix the Malaysian consistently set fastest laps to work his way up to the front and for a while looked like winning.
Julian Simon who also lead for a while was next to finish in fifth for the Blusens Avintia Team while Andrea Iannone was classed as sixth despite a crash just before the flag for Speed Master.
Mika Kallio recovered from being forced off in the opening lap accident between Johann Zarco and Xavier Simon, both of whom had their race end then and there. The Marc VDS man found himself down in 26 but rode his way back to seventh.
Bradley Smith had taken the front at the first corner but faded back a little to finish eighth for Tech3. Dominique Aegerter was ninth for Technomag and Tito Rabat stole tenth from Tuenti Movil HP 40 team mate Pol Espargaro.
Twelfth was taken by British rider Scott Redding for Marc VDS while Elias secured 13th for Italtrans. Axel Pons took the final championship point for the Pons team.
Takaaki Nakagami went off track at the opening corner but rejoined only to then be pushed off track on the Italtrans by Brazilian youngster Eric Granado's JIR.
Simone Corsi was handed a penalty for a jump start on the Ioda.
Marquez will carry a 48-point lead into next weekend's penultimate round in Australia.