Starting from second on the grid, Stoner passed pole sitter
Dani Pedrosa into turn one and - despite running wide at the final hairpin - still held the advantage over Pedrosa,
Randy de Puniet and Melandri as the 20-rider field crossed the line at the end of lap 1 of 21.
The top four then began to stretch away from de Puniet's Kawasaki team-mate
Anthony West, who was later given his second ride-through penalty of the season - this time for starting from the wrong grid position.
Stoner was ultimately never overtaken, but the 22-year-old was never able to break more than two-seconds clear of the two RC212V riders. Melandri snatched second from Pedrosa just before the halfway stage and, despite Stoner smashing the 990cc lap record on lap 15, Marco had closed to within one second of Casey with three laps to go.
But the Australian responded to the pressure from his 2008 team-mate in typical style, quickly putting vital tenths between himself and the Honda Gresini rider on his way to a 1.7secs victory margin, while Pedrosa prevented a
Bridgestone podium sweep with third on his Michelin-shod factory Honda.
de Puniet was firmly in contention for his second podium of the season for much of the race, despite a heart-stopping slide on lap four, but had faded to 1.4secs from Pedrosa by the chequered flag and then stopped on the slowdown lap after running out of fuel.
Meanwhile,
Valentino Rossi had dropped from ninth on the grid to eleventh at turn one, but his race pace was better than he had feared and the Italian was able to salvage fifth at the flag - making him the second best Michelin rider - as the Fiat Yamaha star finished 4.7secs from Stoner.
Melandri's team-mate
Toni Elias claimed a solid sixth, after a tough battle with Repsol rider
Nicky Hayden ended with the American running off track at the final hairpin when he tried to outbrake the Spaniard on lap 13.