Melandri led from start to finish, but Hayden was with him every step of the way and was right on Melandri's rear Michelin as the Italian headed for the fast left hander that leads into the final turn, for the final time.
As the pair slid their rear wheels over the crest, Melandri bobbled slightly - a mistake that looked like it could hand Nicky the race. Certainly Melandri seemed to think so and he responded with a tight defensive line into the last turn.
Hayden stayed wide and cut back in on the exit to try and out-drag his rival to the chequered flag, but Melandri kept his composure and a tidy exit allowed the young Italian to keep his Movistar machine clear of the Kentuckian by just 0.097secs.
Melandri's biggest mistake of the day came when he dropped his RCV while celebrating with the fans - while Hayden, who had been left punching the fuel tank with frustration as he crossed the line, took a few corners to regain his usual friendly demeanour.
Melandri's second win also confirmed second in the 2005 riders' world championship, marking an amazing jump in form for a rider who was just 15th overall in 2003 and 12th in 2004.
"I just can't explain how I feel at the moment. For the last two years I've ended the season injured. This year is so different," said Melandri. “When I saw Nicky was behind I tried to escape but he was too strong. I thought about letting him pass, but I know how hard it is to overtake at this circuit. It was a very tough and Nicky pushed me very hard. On the last bend, I got the bike sideways but I managed to get to the line in front.”
Valentino Rossi suffered a high-speed fall in qualifying, leaving him 15th on the grid, but worked his way through the field to end another title-winning season alongside Melandri and Hayden on the podium.
=6. 2004 Australian Grand Prix - Phillip Island (990cc):
Valentino Rossi wins by 0.097sec over Sete Gibernau.
At times the 2004 MotoGP season, Valentino Rossi's first with Yamaha, looked like it was straight from a Hollywood script - no more so than when Rossi clinched the world title with a dramatic victory at Phillip Island.
The Australian Grand Prix was the penultimate round of the year and Rossi won Yamaha's first premier-class championship since 1992 with a heart-stopping last lap victory over title rival Sete Gibernau.
Rossi - who could afford to settle for second to clinch the title - proved he had no intention of doing so by squeezing past Gibernau's Telefonica Honda at the start of the last lap.