Hamilton fought back to close a seven-second margin after a spin at about one-third distance just as he appeared to be set to take the lead.
But Rosberg did just enough to hold him off in a tense final part of the race.
It reduces Hamilton's advantage in the title to 17 points, with 50 available in the final race in Abu Dhabi.
"I'm very happy with the whole weekend," said Rosberg. "I've been feeling comfortable in the car and controlled the gap to Lewis in the race."
Hamilton can win the title by finishing second to Rosberg in Abu Dhabi on 23 November, even though double points will be on offer.
But the Englishman may rue a half-spin on lap 28 which, as it turned out, decided the race in Brazil.
Double jeopardy: Hamilton v Rosberg for the titleHamilton now has a 17-point lead over Rosberg with a maximum of 50 points remaining at the final race in Abu Dhabi. Hamilton can win the title by finishing second to Rosberg in Abu Dhabi. Third or lower and Rosberg is champion if he wins
Rosberg had made his second pit stop on lap 26, with Hamilton less than two seconds behind him.
Hamilton stayed out. He set the fastest lap of the race to that point next time around, having set three sectors that were the fastest anyone had set up to that point.
The Mercedes engineers calculated that his first lap had not been enough to leapfrog him ahead and decided to keep him out for one more lap to give him extra time to build the advantage he needed.
But he dropped a wheel on to the white line on the entry to Turn Four, the Descido do Lago and ran wide into the run-off area, half-spinning.
Hamilton said: "Ultimately it cost me the win. I was a much quicker up to that point. I went a second quicker, thought I was going to pit on that lap, used all my tyres and on the next lap there was nothing left.
"I locked the rear and went wide. No-one's mistake but mine."
The incident cost Hamilton seven seconds, which he reduced to two over the course of their third stint.
Rosberg came in first for his final stop, on lap 50, with Hamilton making his a lap later, and their battle resumed with them half a second apart on lap 52, 19 from the finish.
Hamilton, clearly faster, stayed within a second of Rosberg for the remainder of the race but was never close enough to make a passing attempt.