Alex de Angelis passed Stefan Bradl on the last lap and then survived a punt up the rear from the German to take his first Moto2 victory of the year at the Australian Grand Prix at Phillip Island.
Bradl's second place, however, allowed him to retake the championship lead from Marc Marquez, who nevertheless took an amazing third place from the back of the 38-bike grid.
De Angelis made a bad start from pole position on his JiR Motobi and looked to be out of the picture when Bradl passed him for fifth place under braking for the MG hairpin on lap three.
The pair hit the front as early as lap five, however; Bradl using a slipstream down the start/finish straight, to put his Kiefer Kalex ahead of Scott Redding's Marc VDS Suter, and de Angelis then unceremoniously shoving the British rider wide at the Doohan corner.
The pair were rarely more than half a second apart after that, and traded the lead a few times during the middle of the race.
The crucial moment came on the final lap. De Angelis took the lead into Doohan, but was then hit up the rear by Bradl under braking for the next corner. While the San Marinese rider kept control of his bike, Bradl had to work hard to keep his on the asphalt and avoid running onto the grass.
He finished 1.358s behind de Angelis, who won for the first time since last year's Australian Moto2 race.
After being given a one-minute qualifying penalty for taking off Ratthapak Wilairot during practice, Marquez delivered a typically charging performance. He made it up from 38th to 16th by the end of the first lap and kept on climbing.
By lap five the Spaniard was into the top 10 and the Catalunya Suter rider then dispatched a gaggle of riders, including Pol Espargaro, Andrea Iannone, Thomas Luthi and Redding to pull himself up to fourth.
It took him another handful of laps to close onto the tail of Claudio Corti, whom he passed for third with seven laps remaining. Undeterred, Corti kept his Italtrans Suter on his rival's tail and made several unsuccessful attempts to wrest the final podium spot on the last lap.
While Corti's fourth spot represented a career-best in Moto2, Marquez's podium finish means his championship deficit to Bradl is just three points, when it could have been far worse.
Espargaro finished fifth on his Speed Up FTR after earlier surrendering the lead by running wide at Siberia, while Kenan Sofuoglu (Technomag Suter) and Redding were next up.
Iannone (Speed Master Suter) was eighth, benefitting from Mike di Meglio running wide and losing a handful of places on his Tech 3 at half distance.
Yuki Takahashi (Gresini Moriwaki) completed the top 10 after first Bradley Smith (Tech 3) and then Luthi took trips through the gravel; the latter after tagging the rear of Espargaro's bike going into Doohan.
Results to follow...