Heading into the Portuguese Grand Prix, the previous four races had seen relatively dull start-to-finish processions by Pedrosa, in Germany, then world championship leader Casey Stoner at Laguna Seca, Brno and Misano.

But, while Stoner once again took the lead into turn one, the Portuguese GP provided action right to the chequered flag, with Rossi working his way up from fifth at turn one to slot into third - behind Stoner and Pedrosa - by lap 3 of 28.

Pedrosa, whose Honda looked all but equal to Stoner's powerful Ducati along the main straight, slipstreamed past Casey to take the lead for the first time on lap seven - and the young Australian lost a further position when Rossi outbraked the 21-year-old into the first turn on lap nine.

The former seven-times world champion, who conceded his 2007 title chances following an engine failure last time out at Misano, then overtook Pedrosa at the same place a lap later to finally return to the head of a championship he once dominated.

Pedrosa and Stoner rose to the challenge and were both within half a second of Rossi at the halfway point, but thereafter Stoner - the only Bridgestone rider in the top four at the finish - slipped back slightly. By contrast, Pedrosa re-passed fellow Michelin rider Rossi for the lead on lap 16 and kept the position until four laps from the end, when the young Spaniard ran wide at turn one while under pressure from the Italian. Dani soon regrouped and just half a lap later Rossi made a similar error, putting the Repsol rider back in front.

Pedrosa was still narrowly ahead as the penultimate lap began at which point Rossi, slower on the straight but better on the brakes, plunged down the inside of the #26 into turn one... it didn't work. Rossi ran wide, but he maintained enough momentum for a second attempt several turns later and this time held his line.

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