Marc Marquez wins titanic duel with leader Jorge Martin at Australian MotoGP
The Spanish Gresini rider had a horror start but recovered to hunt down Pramac's Martin and lunge past with four laps left for his fourth victory at Phillip Island.
While Marquez won, Martin bolstered his lead over Ducati's Italian defending world champion Bagnaia to 20 points in the title race with three race weekends left.
Ducati-VR46 rider Fabio Di Giannantonio came fourth ahead of Bagnaia's teammate Enea Bastianini and Pramac's Franco Morbidelli.
"I thought at one time it was impossible to catch Martin, but in lap five, six, I start to get the rhythm," said Marquez, who also won in Australia in 2015, 2017 and 2019.
"It's true that Martin pushed all the race, but I was saving the tyre for the last attack."
Martin was fast all weekend, blasting to pole position and leading from start to finish in Saturday's sprint race where Bagnaia finished fourth.
While the championship is effectively a two-horse race, six-time world champion Marquez's victory kept him in the picture.
But at 79 points behind, he only has a slender chance to spoil the party.
Wheelspin at start
The circuit moves to Thailand next week before Malaysia and the season's finale in Valencia.
On a sunny but windy afternoon, Martin held his lead into the first corner and put the hammer down.
Marquez though had a huge wheelspin when the lights went out and plunged from second to seventh as Bagnaia manoeuvred up to second from fourth.
He had removed a helmet visor tear-off seconds before the start, and the clear plastic layer was caught under his rear wheel.
"I never pull the tear-off at the start because it's dangerous, but this time when I was engaging the front start device there was something big (on the visor) and I take it off," he said.
"I saw it and it was impossible to take from under my wheel, and when I released the clutch I start to spin."
After three laps Martin had a 0.7sec advantage over the Italian.
But Marquez refocused and began clocking fastest laps - including the first-ever under 1min 28sec in race conditions at the waterfront circuit.
It propelled him back in touch with Bagnaia, who himself was closing on Martin.
Marquez made his move on the Italian on lap 12 of the 27-lap race to go second, signalling a battle was on for first.
With 10 laps to go, Martin was just 0.225sec clear of Marquez with Bagnaia drifting 1.7sec behind.
Marquez pounced with four laps to go when Martin went wide at turn four to take the lead for the first time.
Martin snatched it back a lap later before Marquez almost immediately responded to take his third victory of the season.