The McLaren driver led away from pole position and was able to manage the gap to Raikkonen's team-mate Romain Grosjean during the first two stints of the 69-lap race.
Raikkonen's stunning pace during the middle stint leapfrogged the Finn from fifth to second, but he could not prevent Hamilton taking a 19th career win, his third in Hungary, as Grosjean gave Lotus a double podium by coming home third.
Reigning world champion Sebastian Vettel narrowly failed to overhaul Grosjean after a late stop for fresh tyres and finished fourth.
Championship leader Fernando Alonso would have been a relieved man as Ferrari's lack of pace was not punished in the championship standings.
In fact the Spaniard increased his lead to 40 points as nearest challenger Mark Webber trailed home eighth, after the Australian's own late stop for tyres failed to work out.
Hamilton remains 47 points adrift of Alonso in fourth place despite his masterful drive to victory.
Sixth placed Jenson Button was another left frustrated by strategy as McLaren's decision to switch him from a two to a three-stop option saw him drop from third back to an eventual sixth, ahead of the Williams of Bruno Senna.
Felipe Massa and Nico Rosberg rounded out the top 10.
Hamilton, like team-mate Button running with messages of support for the British Olympic team on their McLarens, had appeared to have the race well under control as he kept Grosjean at arms length during the early going.
The race had proved to be rather processional until Raikkonen shook things up.
Watch: Hamilton wins Hungarian Grand Prix.. More Videos
The Iceman was inspired during his 25-lap stint on a set of used soft tyres in the middle stint of the race, his spectacular pace allowing him to get ahead of Vettel and emerge side-by-side with team-mate Grosjean as he exited the pits.
Raikkonen rudely elbowed his team-mate out the way as they exited turn one and set off in pursuit of Hamilton.
For several laps the former Ferrari man was within a second of Hamilton but with DRS having a minimal impact on the twisty Budapest track he and his team were left frustrated as Lotus continue to wait for their first win of the season.
Hamilton moves within one of the record tally of wins in Hungary, held by Michael Schumacher with four.
But the German's miserable weekend saw him force a delay to the start, meaning the race distance was cut by a lap from 70, as he switched his engine off on the grid believing it was overheating.
When he did get under way he was given a drive-through penalty for speeding in the pitlane and eventually retired his Mercedes.
The win is a timely boost for Hamilton as the sport enters into a month-long summer break before hostilities resume in Belgium at the start of September.
The Briton said: "It's been an amazing day, fantastic work by all the team.
"I am looking forward to the continuation of the championship. A long way to go and a lot of work to do but we have shown we can compete. It is very, very close but we are going to give it all we can."
And team boss Martin Whitmarsh admitted it was a result the team needed as they continued their recent upturn in form after being comprehensively outpaced at Valencia in Silverstone.
He told Sky Sports F1 "We needed it, we knew we had to improve the car but we needed to get points in the bag.
"We are hauling ourselves up in the constructors' championship, and Lewis has cruised up behind that second echelon of drivers in the championship.
"We said before this race that there are 430 points available in the rest of the championship. We didn't get as many as we wanted this weekend but we have a decent haul.
"If we can do it week in week out there is no reason we can't be in Brazil at the end of the year fighting for both championships."
Despite still waiting for a first win of the season, Raikkonen was satisfied with his second place.
He said: "It's not enough but we had some problems with the KERS. "We had some speed and we'll try to win the next race.
"At least we are up there all the time and we put ourselves in a good position but we are not happy until we win."