Not that the Mercedes driver expected to win his first race since the United States GP last November, saying beforehand he would need "a miracle" despite qualifying in pole position for the third time in a row.
"I was hungry for it today," Hamilton said. "I was going for every move I could."
Hamilton beat Kimi Raikkonen of Lotus by 10.9 seconds and finished 12.4 ahead of Red Bull driver Sebastian Vettel, who still moved further ahead in his quest for a fourth straight Formula One title.
Mercedes has been quick in qualifying all season but has struggled with its tires during race day. However, they held up on a Hungaroring circuit in which temperatures reached 51 degrees Celsius (123 Fahrenheit).
"We've got to keep working hard," Hamilton said. "But if we can come here and make them last (then) anything is possible."
Equaling one famed drivers' record drew praise from another.
"He drove sensationally, the best I've ever seen him drive," said non-executive Mercedes chairman Niki Lauda, a three-time F1 champion. "We were not as quick as the Red Bull, but Lewis made it all up with the way he passed people."
Vettel was frustrated at failing to overtake Raikkonen late in the race.
"I would have loved the race to have been a bit longer," Vettel said. "I got close but I wasn't in the prime overtaking spot at that point."
Vettel headed into the weekend 34 points clear at the top and added four more to his lead as the race enters its mid-season break. The next race is the Belgium GP on Aug. 25.
The German has 172 points, 38 in front of Raikkonen and 39 ahead of Ferrari driver Fernando Alonso, who finished fifth to slip behind Raikkonen overall. Hamilton has 124 to sit fourth.
Alonso was referred to race stewards for using his DRS system — a strictly controlled device that helps overtaking — on three occasions when he was not allowed to. He kept his points but Ferrari was fined €15,000 ($19,910).
Hamilton managed his tires wisely to earn his 22nd win. Coming into the race, he had been third three times. But he also won from pole in Hungary last year, and he kissed his Mercedes car and hugged team boss Ross Brawn following Sunday's victory.
"We were on the back foot when we came in," Hamilton said. "I feel like I really earned my keep today."
The Briton was in no mood for compromise during the race, snapping at an engineer over the race radio after receiving some late advice: "Hey man, I'm trying to drive here. I'm happy with the way the car is."
Meanwhile, teammate Nico Rosberg had to withdraw near the end with flames billowing from the back of his car. He was unhurt.
Vettel has four wins overall, having won the German GP three weeks ago, but his tire option didn't work out.
"The start was difficult, and when Lewis pulled in we thought we could do it on the softs," Vettel said. "I damaged my front wing, which did not help. We wanted a little bit more today."
He tried desperately to get past Raikkonen, and they almost collided on the next-to-last lap. Vettel thought the Finn should have given him more room.
"I told him but he was laughing," Vettel said.
Meanwhile, the pressure was on tire manufacturer Pirelli.
The teams recently held in-season testing sessions at Silverstone to assess new tires provided by Pirelli, after several spectacular blowouts on the same circuit at the British GP in June prompted a boycott threat from drivers.
Pirelli decided that from this race until the end of the season it will revert to last year's tires combined with the current compounds from this season.
"The first time ever I can remember my tires not being a problem," Hamilton said.
With 14 corners and short straights, the Hungaroring is the second most difficult track for overtaking after Monaco — although it has a long run down to Turn 1. Hamilton held his racing line perfectly on it to get an early boost.
Lotus driver Romain Grosjean, who started third and finished sixth, tried to pass inside Vettel before the first turn, but the German moved to the right.
Rosberg went wide on Turn 5 and onto the grass, and then shortly after nudged into Felipe Massa's Ferrari to dislodge the Brazilian's front wing.
Staying out longer on medium-compound tires, Button blocked Vettel to allow Hamilton to streak ahead.
Grosjean was given a drive-through penalty for leaving the track and gaining an advantage, while an earlier collision with Button saw him receive a 20-second time penalty. It made no difference to the race positions.