The last lap began with Rossi 0.17secs ahead of Pedrosa, and ended with Rossi 0.175secs ahead for his fourth victory of a difficult season - while Stoner, who later revealed he had been suffering clutch problems, settled for a safe third 1.3secs behind a disappointed Pedrosa.
Rossi took the chequered flag almost without expression as he came to terms with the end of his worst run since 2000, then - willed on by a chanting crowd - stood with his hands on his hips before demonstrating his full repertoire of wheelies and burn outs. Rossi dedicated his victory to rally legend
Colin McRae, who was killed in a helicopter accident on Saturday.
Stoner now leads the standings by a reduced 76 points and needs to leave next weekend's Japanese Grand Prix with a lead of at least 75 points over Rossi to be crowned the 2007
MotoGP world champion at Motegi.
Meanwhile, pole sitter
Nicky Hayden fought back from an early race slump to take fourth position, while Honda Gresini's
Marco Melandri won a battle with Suzuki's
John Hopkins for fifth.
Carlos Checa was a lonely seventh, while 2006 race winner
Toni Elias produced some exciting slides on his way to a hard fought eighth as he continues to recover from his broken femur.
Stoner's factory Ducati team-mate
Loris Capirossi collected ninth, while Rossi's Fiat Yamaha team-mate
Colin Edwards was tenth.
Portuguese Grand Prix:
1. Rossi
2. Pedrosa
3. Stoner
4. Hayden
5. Melandri
6. Hopkins
7. Checa
8. Elias
9. Capirossi
10. Edwards
11. Nakano
12. West
13. Vermeulen
14. Guintoli