Before the start, Hamilton had spoken of Hungary fast becoming one of his favourite circuits.
Winner four times previously at the Hungaroring, he had dominated practice and qualified more than half a second quicker than Rosberg, who started next to him on the front row of the grid.
- Hungarian Grand Prix: Vettel wins for Ferrari and Bianchi
Both Mercedes drivers were passed by the Ferraris after an aborted first start, caused by the Williams of Brazilian Felipe Massa being out of position, and the afternoon then became a hard slog in dirty air.
Hamilton, already fourth, went wide at the chicane on the first lap and fell down to 10th.
Yet even when Hamilton had dropped down the order, a victory still looked possible with the Briton lapping more than a second a lap faster than Rosberg and clawing his way back to fourth place.
The deployment of the safety car, after Force India's Nico Hulkenberg had crashed, further bunched up the leaders and helped his hand.
But Hamilton then collided with Australian Daniel Ricciardo's Red Bull after the re-start, collecting a drive-through penalty and having to make an unscheduled stop for a new front wing.
The Briton even apologised to the team over the radio for his errors.
"I pushed right to the end but there were so many obstacles. It's like there were two different directions and each time I chose the wrong one," said Hamilton.
With Rosberg running in second place, and looking like he could win and take the championship lead, Hamilton had Ricciardo to thank for then wrecking his team mate's race with a late collision.
Rosberg suffered a puncture and finished eighth.