Rosberg led from start to finish in Spain
Hamilton was initially stuck behind Ferrari?s Sebastian Vettel but switched to a different strategy to get ahead.
Mercedes decided to make one more pit stop than Vettel and, in clear air, Hamilton had extra speed and rejoined from his final stop ahead of Vettel.
The German was third ahead of Williams? Valtteri Bottas and Kimi Raikkonen.
It was Mercedes? most dominant grand prix since the first race in Australia.
Ferrari had come to this weekend with a major upgrade package, with revisions to almost every aerodynamic surface of the car, but Mercedes were perhaps further ahead than they had been all season.
Rosberg converted his pole position into a lead at the first corner and simply cruised into the distance as Vettel held up Hamilton behind him.
Mercedes urged Hamilton to try to pass the Ferrari, but he told the team it was impossible to get close enough to overtake on the pit straight even with the help of the DRS overtaking aid.
Mercedes decided their best option was to give Hamilton some clear track, and told him that they would switch to a three-stop strategy and try to pass Vettel at the end of the race.
But Hamilton did not need to overtake the Ferrari on track.
Stopping on lap 32 to fit the slower ?hard? tyre, Hamilton immediately set the fastest lap of the race and proceeded to take huge chunks out of Vettel?s advantage.
Twenty seconds behind when he rejoined, Hamilton had cut Vettel?s lead in half by the time the Ferrari driver made his second and final stop eight laps later.
Vettel rejoined 13.5 seconds behind Hamilton, who continued to pull away until he was 23 seconds in front by the time of his final stop on lap 51, which was comfortably enough to allow him to rejoin in front of the Ferrari.
Now 17 seconds behind Rosberg, Hamilton fancied his chances of catching his team-mate for the win, but was told by his engineer Peter Bonnington that he had too much to do and to ?consolidate? second place.
Hamilton pressed Bonnington, saying: ?Is it impossible?? He was told: ?Yes, it?s impossible. He?ll respond if we pick up the pace.?
The result means Rosberg has reduced Hamilton?s advantage in the championship to 20 points, while Vettel is 31 points adrift in third place.
?Perfect weekend,? said Rosberg. ?The car has been awesome ? all weekend.?
Hamilton said: ?I got a bad start, had lots of wheelspin but it was a good race. Nico did a fantastic job and I was just grateful I could get back up to second. This was a difficult weekend for me and I?ll take this.?
Behind Vettel in the race, Bottas took fourth, fighting off a stern challenge from Ferrari?s Raikkonen in the closing laps.
Ferrari inverted Raikkonen?s tyre strategy, putting him on the ?hard? tyre for his middle stint rather than taking the conventional route of leaving it for the end of the race.
That meant Raikkonen had a grip advantage over Bottas, who was on the ?hard? tyre in the final stint, but he was unable to make it pay.
The second Williams of Felipe Massa was sixth, from the Red Bull of Daniel Ricciardo and Lotus?s Romain Grosjean.
Toro Rosso?s Carlos Sainz passed Red Bull?s Daniil Kvyat for ninth place at the first corner of the last lap, but faces a stewards? investigation because he went off track through Turn Two as he completed the move. Gaining an advantage by leaving the track is forbidden.
Three laps earlier, Sainz cleanly passed team-mate Max Verstappen for 10th place.
The two Toro Rossos had started fifth and sixth and had always suspected it would be tough to beat Raikkonen, Massa and the Red Bulls, all of which had qualified behind them.
Sainz took advantage of being on the ?medium? tyres in the final stint while Verstappen was on the ?hard?. The Dutchman ran wide in the final twisty section of the track on lap 62 and Sainz was able to draft past on the straight.
Jenson Button finished 16th after a troubled race for McLaren.
Team-mate Fernando Alonso ran 12th in the first stint, climbed as high as seventh at one point thanks to a late first pit stop, but retired from 14th place with brake failure.