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.