Hamilton survived a scare at the start, when he ran wide at the first corner after locking a front tyre.
But otherwise he was untroubled en route to his 51st career win.
In the championship, the result changes little, and Rosberg can win the title by finishing second to Hamilton at the last two races of the season.
Hamilton is 19 points adrift with a total of 50 available in Brazil and Abu Dhabi.
Rosberg can now regroup after a weekend on which Hamilton was in almost total control throughout.
The German will doubtless keep to his well-worn mantra that he is taking it one race at a time and trying to win each one, but he has the luxury of knowing he can afford to take it easy in both remaining races and clinch his first world title.
Rosberg also had a scare, and a more eventful race than Hamilton, as 120,000 fans had little to excite them under blue skies and warm sunshine in Mexico City, until some frantic and bad-tempered late action in a battle over third place between Red Bull's Max Verstappen, Ferrari's Sebastian Vettel and Red Bull's Daniel Ricciardo.
Hamilton spent the first stint controlling his pace to ensure he did not overwork his damaged tyre, while Rosberg was under pressure from Verstappen.
Rosberg and the Dutchman had collided at the first corner as Verstappen tried to take second place, Rosberg taking to the grass behind Hamilton after the collision.
The incident was investigated by the stewards but given the all-clear.
It was a foretaste of what was to come.
As Hamilton controlled the race - on the way to a victory that puts him equal with Alain Prost in second place in the all-time winners' list, with Michael Schumacher way ahead on 91 - Rosberg spent much of the afternoon watching his mirrors for Verstappen.
There was stalemate for a long time, until Rosberg locked up into Turn One on lap 50 while trying to lap Toro Rosso's Carlos Sainz.
Verstappen saw his opportunity and dived down the inside into Turn Four. Although he was briefly ahead, he could not stop in time and ran wide, sliding across the track on opposite steering lock, and Rosberg regained the place.
It was Verstappen's one and only chance. Once he was back up to speed, the gap was out to 2.5 seconds and Rosberg edged gently away for the rest of the race.
Red Bull's gamble of starting on the super-soft tyres to try to mix it with the Mercedes did not really pay off, but it led to a dramatic battle in the closing laps.
Instead of challenging Rosberg, Verstappen found himself under pressure in the closing laps from Vettel and Ricciardo.
Vettel started on the soft tyre like the Mercedes and ran a very long 33-lap first stint, leading for 16 laps after Hamilton's first stop.
That gave him tyres that were 20 laps fresher than Verstappen's for the final stint and he closed in inexorably until he was within 1.2secs with six laps to go.
Verstappen locked up at the first corner on lap 68 and ran wide over the grass, cutting the corner and keeping hold of third place, the German complaining he should be given the position as Verstappen was advised by his team to hand it over.
But Verstappen kept fighting as Vettel tried to pass, the four-time world champion claiming the Dutchman was backing him into Ricciardo, who fought back through the field after a first-lap stop put him on a two-stop strategy.
The three were nose to tail at the start of the penultimate lap and Vettel was right on the edge in holding Ricciardo back as he tried to pass into Turn Four.
The incident spread the gap between the three cars and Verstappen crossed the line in third, from Vettel and Ricciardo.
But Verstappen's cutting of the first corner was investigated by the stewards on the grounds he might have gained an advantage by leaving the track and in dramatic scenes Verstappen was given a five-second penalty immediately after the race and was demoted to fifth.
Verstappen was forced to leave the pre-podium room as Vettel ran to take up his place on the podium.
However, in a further twist, Vettel then lost third place after becoming the first driver to be punished under a new dangerous driving rule for his defence against Ricciardo's attempted pass.
Vettel was penalised 10 seconds for moving while in the braking zone and given two penalty points on his licence - ending up fifth and Ricciardo eventually being classified as third.
Vettel had earlier fumed over the radio, using several expletives in telling his team how unhappy he was with race director Charlie Whiting.
He and Verstappen then gesticulated at each other after crossing the line, Vettel wagging his finger at Verstappen.
Lewis Hamilton: "This is honestly the best crowd we get anywhere. In our home country it is always great, but these guys have such a great passion.
"I love it here. I have had tacos every night.
Media playback is not supported on this device
"Nico is doing a great job. I'm really grateful the team did a great job."
Sebastian Vettel on his clash with Verstappen: "I was using a lot of sign language. You have to understand the adrenaline.
"Then obviously he left the track and didn't move and so you can understand why I was annoyed. I was really disappointed when I crossed the line."
Mexican Grand Prix race results
Mexican Grand Prix coverage details
Lewis Hamilton kept his title hopes alive with a comfortable victory from Mercedes team-mate Nico Rosberg in the Mexican Grand Prix.