While fortune finally favoured the triple world champion after a run of bad luck, championship leader Rosberg finished seventh — 93.2 seconds behind — and saw his lead cut to 24 points after six of 21 races.
Australian Daniel Ricciardo was runner-up, a botched second pitstop destroying his chances after he started on pole position for the first time, with Mexican Sergio Perez third for Force India.
“I prayed for a day like this so I feel truly blessed,” said Hamilton, who had cut a disconsolate figure after a fuel pressure problem in qualifying left him third on the starting grid.
The win was the 44th of his career, matching the number on his car, and his first since Texas last October when he took his third championship.
He made the right call on the tyres, with a late change to slicks, and got more mileage out of the ultrasofts than expected. He also made his car as wide as possible with Ricciardo crawling all over the back of him.
Hamilton was congratulated by Canadian pop singer Justin Bieber as he stepped out of the car in the pit lane before the podium celebration.
His jubilation contrasted with Ricciardo’s sense of shock, the Australian feeling robbed of a likely victory by his own team whom he said had called him in for a pitstop and then did not have the tyres ready.
“Two weeks in a row I’ve been screwed,” said the driver, who had also led in Spain two weeks ago until a strategy error handed the advantage to 18-year-old Dutch team mate Max Verstappen, who became the sport’s youngest winner.
“It sucks. I was called into the box. They should have been ready.”
“Nothing you can say can make it any better,” Ricciardo had told the team over the radio after the chequered flag. “Just save it.”
Ricciardo had built up a tidy lead at the start before Mercedes told Rosberg, then in second place, to let Hamilton through on lap 16 because the German was suffering from high brake temperatures.
The race had started with seven laps behind the safety car in wet conditions, dried out and then ended with more rain threatening and cloudy skies.
Ferrari’s Sebastian Vettel finished fourth, while Finnish team mate Kimi Raikkonen retired with his front wing wedged awkwardly under the car after clouting the barriers on the 12th of the 78 laps.
Raikkonen continued through the tunnel with sparks coming from his car before parking up at the exit.
McLaren’s Fernando Alonso was fifth, on the 50th anniversary of his team’s race debut in Monaco in 1966, with Force India’s Nico Hulkenberg snatching sixth from Rosberg at the very end.
Spaniard Carlos Sainz was eighth for Toro Rosso, ahead of McLaren’s Jenson Button and Brazilian Felipe Massa in a Williams.
The safety car had barely come in, with Hamilton among those chafing at the amount of time it had been deployed, before Renault rookie Jolyon Palmer lost control and crashed at the first Sainte Devote corner.
That led to a Virtual Safety Car being declared, one of several uses during the afternoon.
Verstappen, who crashed in qualifying and had been due to start from the pit lane, made some impressive overtakes but his race came to an end just before the half distance when he hit the barriers on the approach to Casino Square.
Renault’s Kevin Magnussen smashed his car’s front wing off when he nosed into barriers and the two Saubers then drove into each other at Rascasse corner, triggering another virtual safety car deployment.
There was another deployment 10 laps from the end when what looked like a large tarpaulin, or plastic sheet, had to be retrieved from the track by a marshal.