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.