Dovizioso's team-mate Cal Crutchlow - who had followed Rossi up the order throughout the race - also got by Hayden on the final lap, leaving the American an undeserved seventh.
Stoner crossed the line 30 seconds from Lorenzo in eighth and is now 37 points behind in the championship.
Stoner began the grand prix fifth on the grid, after struggling to find an optimum set-up all weekend and was the only rider to choose the 'special' hard construction rear, offered as an additional harder-spec option as a precaution following the Assen issues.
The Australian moved gradually up the order from eighth on lap one to fifth, in front of Hayden, when he ran through the gravel after missing his braking point into a downhill right-hander just before the halfway stage.
Stoner rejoined in tenth and later passed San Carlo Honda Gresini's Alvaro Bautista (with a little contact) and Pramac Ducati's front row starter Hector Barbera.
Ben Spies suffered another nightmare race, dropping from seventh to eleventh and last of the manufacturer riders.
Leading CRT rider Randy de Puniet
(Aspar) finished just two-seconds behind Spies' Factory Yamaha, while Aleix Espargaro (Aspar), James Ellison
(PBM) and Mattia Pasini (Speed Master) completed the point scorers.
Ivan Silva (BQR) was the final finisher, one lap down in 16th.
Colin Edwards was among the retirements on what is rumoured to have been his final race on the Suter-BMW - the Forward Racing team being expected to test rival machines on Monday.
Greisni's Michele Pirro was disqualified for taking a short cut back to the pits after problems on the opening lap.
Cardion AB Ducati's Karel Abraham, who suffered left hand injuries sustained in testing at Aragon, missed Mugello and was not replaced.
Mugello was the third event in the space of three weeks. MotoGP
teams and riders will return on Monday for a day of testing, then enjoy a weekend off before the US Grand Prix at Laguna Seca.
Honda will provide Stoner and Pedrosa with a 'completely new' RC213V to try at the test.
1. Jorge Lorenzo
2. Dani Pedrosa
3. Andrea Dovizioso
4. Stefan Bradl
5. Valentino Rossi
6. Cal Crutchlow
7. Nicky Hayden
8. Casey Stoner
9. Hector Barbera
10. Alvaro Bautista
11. Ben Spies
12. Randy De Puniet
13. Aleix Espargaro
14. James Ellison
15. Mattia Pasini
16. Ivan Silva