With 10 to go Rossi had a slim but significant 1.5secs lead, while Biaggi was being forced to defend second from Hayden, until the American got frightening sideways under braking into turn one, forcing him to ride wide (after narrowly avoiding hitting the back of Biaggi's machine) - handing Bayliss third and Tamada fourth in the process.
Hayden's fortunes would get even worse a lap later when he lost the front of his RCV heading onto the back straight – did all he could to lift it – but then, inevitably, span out into retirement... much to the dismay of the watching Michael Jordan.
The #69's downfall provided Gibernau with fifth position, and the home hero would mount something of a revival in the closing stages, catching and then passing long time leader Tamada into the final turn, to claim fourth position with two laps to go.
Meanwhile, all attention was back up front as a charging Biaggi began to close Rossi's lead from 2secs to just 1 as the last lap began. The tension in the Yamaha pits increased further as the Roman dropped the gap to 0.8secs at the end of the first sector, and then 0.7secs at the next checkpoint, before taking the final chequered flag of the 2004 season just 0.4secs behind the victorious Rossi.
The win was Rossi's ninth of the year - matching his achievements with Repsol Honda in 2003 - and, despite Ducati bound team-mate Carlos Checa falling on his way to 14th, it was enough to hand the Gauloises Fortuna Yamaha team the 2004 teams' world championship.
The man Checa has now been confirmed as replacing at Ducati, Troy Bayliss, took the flag 2.7secs back for his first podium of the season and his fourth and final top three on a Desmosedici.
The Australian also equalled the Marlboro team's best finish of the season and beat Loris Capirossi, who never featured at the front today, by six places and 25-seconds – doing his 2005 job prospects no harm.
Further back, a clearly disappointed Gibernau duly claimed fourth ahead of Tamada, while Alex Barros
won the battle as best of the rest, after fighting back from a terrible start (he was 14th at the end of lap 1) to finish 9secs in front of Kawasaki's Shinya Nakano.
Nakano's result nets the Japanese tenth in the riders' championship since his rivals for the position, Ruben Xaus and Marco Melandri, both crashed out – Xaus in spectacular cart-wheeling fashion.
Behind Nakano, Colin Edwards
had a disappointing final race for Telefonica Honda; the Texan was ninth on lap one and just one place higher 30 laps later.