The race came down to the wire, as Rossi and Marquez exchanged hold of the lead in the final laps - but a minor mistake from Marquez allowed “The Doctor” cruise across the chequered 2.6 seconds ahead of his Spanish rival.
While it was a triumphant finish for Rossi - the start of the race was one that the Italian rider would like to forget, as he quickly dropped from fifth on the grid into seventh, while his Yamaha team-mate Jorge Lorenzo shot into the lead on the first corner.
Within the first two laps, the leading pack started to form - as Lorenzo led from the Repsol Honda duo of Marc Marquez and Dani Pedrosa, with Suzuki’s Maverick Vinales in close pursuit.
Rossi quickly amended his early mistakes, as he shot past the Ducati of Andrea Iannone and then quickly pushed past Vinales and Pedrosa by the end of the third lap.
As the laps ticked by, Rossi closed in on the Spanish duo of Lorenzo and Marquez - and on the seventh lap, the Italian rider struck for good, as he passed both riders in quick succession and pushed into the lead.
Once Rossi had moved past his Yamaha team-mate, Marquez was the next to follow - as he made a quick move past Lorenzo and began his pursuit on Rossi in the lead.
Lorenzo’s pace continued to drop drastically, as Dani Pedrosa was the next rider to overtake the reigning World Champion - and Maverick Vinales followed soon after.
On lap 17, things went from bad to worse for Lorenzo, as Andrea Iannone was too aggressive in his attempt to make a pass - which saw his Ducati smash into the back of the Yamaha of Lorenzo and forced both riders out of the race.
As the race wound down into the dying stages, Marquez remained within striking distance of Rossi - and it was with three laps remaining that the young Spaniard finally made his move, roaring down the straight to overtake Rossi and jump into the lead.
However, Rossi made a near identical move on the next lap - as he surged down the straight and pushed past Marquez to take the lead with two laps remaining.
A minor mistake from Marquez saw the Spaniard run wide and allowed Rossi the necessary breathing room to coast across the chequered flags with a gap of 2.6 seconds separating the two riders.
Despite finishing second, Marc Marquez moved into the lead in the World Championship race with 125 points for the season - ahead of the Yamaha duo of Jorge Lorenzo (115 points) and Valentino Rossi (103 points).
Spanish rider Dani Pedrosa completed the podium, which was the Honda riders third consecutive podium finish in Catalunya.
The fans in Barcelona had a lot to cheer about, as homegrown riders Maverick Vinales (Suzuki) and Pol Espargaro (Yamaha) crossed the line in fourth and fifth.
Cal Crutchlow (Honda) had his best race of the season, finishing in sixth position - ahead of Ducati’s Andrea Dovizioso, Aprilia’s Alvaro Bautista and Octo Pramac’s Danilo Petrucci.
Australian rider Jack Miller finished the race inside the top ten, after Hector Barbera lost a position for exceeding track limits. This was Miller’s first top ten finish in his MotoGP career.