Jack Miller trimmed five points back from Alex Marquez's Moto3 championship lead by claiming a home win in an extraordinary finish at Phillip Island.
In recent weeks Marquez, brother of MotoGP world champion Marc, had taken charge of a title race previously led by 2015 LCR MotoGP signing Miller all year, and looked set to further increase his advantage when he qualified on pole in Australia with Miller only eighth.
But Miller was immediately a factor in an outstanding race featuring a nine-bike lead pack throughout.
A minor moment with four laps to go dropped Marquez to the tail of that queue but he quickly fought back, while Miller came out unscathed from a late jostle in which Danny Kent and Brad Binder both crashed.
As the final lap began Marquez led from team-mate Alex Rins and Miller, before Miller managed to draft from third to first as they headed into the first corner for the last time.
He then defended on the run to the line to beat Marquez by 0.029s and Rins by 0.032s, with just 0.044 seconds covering the top four and the top six within 0.242s.
The victory brings Miller back to within 20 points of Marquez with 50 available from the final races at Sepang and Valencia.
CHAMPIONSHIP STANDINGS AFTER 16 OF 18 ROUNDS: