Honda's Melandri claimed his fifth career victory ahead of Suzuki's Chris Vermeulen in a dramatic rain affected race.
Vermeulen won Australia's first home podium finish since multiple world champion Mick Doohan won the 1998 race, while Rossi snatched third at the expense of Spain's Sete Gibernau to keep his championship hopes alive.
World championship leader Nicky Hayden, who slipped to 16th after a poor first lap, ended the race in 5th place, while the currently second placed Dani Pedrosa had a terrible day finishing 15th.
Hayden stills holds a 21 point lead over the fast finishing Rossi with three races to go.
But, it was Melandri's day who never surrendered the lead he took on lap 16.
"I almost fell over myself on the change of bikes. It was difficult when we left the pits, a little scary," the Italian said.
"I saw Vermeulen and Sete going fast so I thought maybe I could too. I said to myself be smooth because it will be difficult for everyone."
There was also drama after the race when Hayden was reported to have claimed Rossi made a passing manoeuvre on Australian Casey Stoner when the yellow flags were on display but no official protest was launched with the stewards.