Rohit top-scored with an unbeaten 121, but the biggest roar was for Kohli, who made ducks in the first two games won by Australia at Adelaide and Perth which clinched them the series.
Ducati's Bagnaia led from pole and crossed the finish line in 19min 53.725sec at Sepang, as Marquez came home 2.259sec behind to create a historic family one-two in the driver standings.
The Wallabies held on after a nerve-jangling finale to set themselves up for their trip to Europe, where they will face England, Italy, Ireland and France on successive weekends.