Brad Binder capped off his title-winning Moto3 campaign with victory in the season finale at Valencia, recovering from 22nd place to pip Joan Mir to the finish line by 0.056s.
The South African rider effectively started from pole after the quickest man in qualifying, Aron Canet, was pulled off the dummy grid after stalling his bike.
But Binder plummeted down the order on the second lap with an off at Turn 6, dropping from the leading group down to 22nd before steadily clawing his way back through the order.
The race was led at that stage by Mir, although the Spaniard was later forced to drop a place, behind the Sky VR46 bike of Andrea Migno, for having taken the lead under yellow flags after a crash involving Gabriel Rodrigo and Francesco Bagnaia.
With 10 laps to go, Binder had made his way up to fifth place behind the leading quartet of Migno, Mir and the Gresini pair of Fabio di Giannantonio and Enea Bastianini.
From there, the champion began to pick his way though his rivals, taking the lead from Mir with four laps to go - only to then drop back again with a small mistake at Turn 2 that dropped him to fourth.
That forced Binder to repeat his moves, with the decisive one coming at the first corner on the final lap. Mir came close to sliding up the inside at the last corner, but Binder held on to take his seventh win of the year by just 0.056s.
"I'm not too sure what happened, I opened the gas twice, the engine cut-out and I high-sided. It did it twice in two corners, so I thought something was wrong," said Binder of his early problem.
"But the bike was alright, carried on going and never had another problem. I never had another problem, and I pushed so hard, and to finish my Moto3 career like this is awesome."
Despite missing out on a second victory, Mir's second place allowed him to seal Rookie of the Year honours, 10 points clear of di Giannantonio - who was fifth behind Migno and Bastianini.
Juanfran Guevara was sixth, followed by Jakub Kornfeil, Philipp Oettl, Jorge Navarro (who took third in the standings thanks to Bagnaia's crash) and the surviving Aspar Mahindra of Jorge Martin.
Still suffering from injuries sustained in Malaysia, the third contender for rookie honours, Nicolo Bulega could do no better than 17th place - two ahead of recovering poleman Canet after his start-line drama.
|5||4||Fabio Di Giannantonio||Honda||0.713|
|6||58||Juan Francisco Guevara||KTM||0.899|
|25||89||Khairul Idham Pawi||Honda||24.526|
|Ret||42||Marcos Ramirez||Mahindra||17 laps|
|Ret||48||Lorenzo dalla Porta||KTM||21 laps|