Casey Stoner snatched victory from Ben Spies in an epic finish to the 800cc MotoGP era at Valencia.
World champion Stoner had been running away with the race for the majority of the event, utterly dominating from pole.
Yamaha rider Spies was embroiled in a huge battle for second with Stoner's Honda team-mates Andrea Dovizioso and Dani Pedrosa, several seconds behind the runaway Australian.
But when rain started to fall in the closing laps, Spies broke away from the Hondas and started closing Stoner down - making it into the lead with two laps to go.
It looked like he had done enough to secure the second win of his MotoGP career, but Stoner got a better run out of the last corner of the race and grabbed the victory on the line by just 0.015 seconds.
Dovizioso claimed third in the championship as he completed the podium, while Pedrosa slipped back to fifth behind Cal Crutchlow. The Tech 3 Yamaha rider battled with Karel Abraham - his rival for rookie of the year honours - until the Cardion AB Ducati crashed, allowing Crutchlow to escape and beat the factory Honda to an exceptional fourth.
Several riders who might have featured strongly in the podium battle were wiped out at the first corner, when a brush between the fast-starting Dovizioso and Alvaro Bautista led to the Suzuki rider falling and taking out the Ducatis of Valentino Rossi and Nicky Hayden, and Pramac Ducati's Randy de Puniet.
Jorge Lorenzo's stand-in Katsuyuki Nakasuga rode well to come through to sixth on the works Yamaha, ahead of an equally brilliant run from American Superbike champion Josh Hayes, who took seventh on his MotoGP debut, replacing the injured Colin Edwards at Tech 3.
Abraham rejoined to take eighth, with Loris Capirossi (Pramac) ending his MotoGP career with ninth place.