Lewis Hamilton won the Hungarian Grand Prix from pole position on Sunday for his first victory of a frustrating season and a record-tying fourth triumph on the Hungaroring circuit.

Kimi Raikkonen was second after holding off a strong late challenge from Sebastian Vettel, who was third ahead of Red Bull teammate Mark Webber.

Hamilton's first year with Mercedes has been tricky, and he came into the race with low expectations of victory despite securing his fourth pole this season and his third in a row.

"This is probably one of the most important Grand Prix wins of my career," Hamilton said after equaling Michael Schumacher's record of four victories here. "I hope there are many more to come."

Hamilton managed his tires wisely to get his 22nd GP win and the first since the United States GP last November. Prior to Hungary, he had been third three times.

"We were on the back foot when we came in, I wasn't even expecting to be on pole," said Hamilton, who also won from pole in Hungary last year. "Four wins, that's incredible. I love it here."

Hamilton remains fourth overall but is likely too far behind to mount a serious title challenge as the season takes its mid-season summer break.

Leader Vettel has 172 points, 38 clear of Raikkonen and 39 ahead of Ferrari driver Fernando Alonso. Hamilton has 124, some 48 points adrift of Vettel.

"I hope today is the first step in (catching up) but we have a lot of races coming up," Hamilton said. "I remember the first time I won, it was an exceptional feeling. Today it was a really calming feeling when I came over the line."

The next race is the Belgian GP on Aug. 25.

After he won, Hamilton kissed his Mercedes and then hugged team boss Ross Brawn. When he raised the winner's trophy, he looked emotional as he pointed to members of his team to share the moment with them.

"The guys have just been phenomenal all year," Hamilton said. "I feel like I really earned my keep today."

During the race, the British driver was in no mood for compromise, however, barking back at an engineer over the race radio, "Hey man, I'm trying to drive here. I'm happy with the way the car is," when he received some late advice.

Teammate Nico Rosberg had to abandon right near the end with flames billowing from the back of his car. He was unhurt.

Vettel has four wins overall, having won at the German GP three weeks ago.

"The start was difficult and when Lewis pulled in we thought we could do it on the softs," said Vettel, who has never won in Hungary. "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 penultimate lap as the Finn blocked his move.

"I had no doubt that I could keep him out," Raikkonen said.

But Vettel thought Raikkonen should have given him more room.

"I told him, but he was laughing. In the heat of the moment, it was quite tight getting in there," Vettel said.

Romain Grosjean started third and finished sixth in an eventful race for the Frenchman.

The pressure was on tire manufacturer Pirelli at this race.

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 Grand Prix in June prompted a furious response and even 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. Soft and medium tires were available for the race and they held up well.

"The first time ever I can remember my tires not being a problem," Hamilton said. "I really hope we're able to do the same" in Belgium.

With 14 corners and short straights, the Hungaroring is the second most difficult track to overtake on 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.

Grosjean tried to pass inside Vettel before the first turn, but the German moved to the right to protect himself.

Rosberg went wide on turn 5 and onto the grass. Dirt and dust flew up from his Mercedes when he rejoined the track, and then shortly after nudged into Felipe Massa's Ferrari. The Brazilian's front wing was clipped and flapped about — providing at least some breeze on a brutally hot day where the track temperature reached 123 Fahrenheit.

Staying out longer on mediums, Webber and Button found themselves playing a key early part in the race. Vettel was stuck behind Button, who was third, and ahead of them Hamilton was behind Webber's Red Bull.

Webber pitted on lap 24 and, with Button still blocking Vettel, Hamilton streaked ahead.

"I guess (Jenson) did me a favor there," Hamilton said about his former McLaren teammate.

Alonso and Vettel pitted together on lap 35, as Hamilton clocked the day's fastest lap.

Grosjean was given a drive through penalty for leaving the track and gaining an advantage and an earlier collision with Button was to be investigated by stewards after the race.

After his final stop, Vettel came out behind the 2007 F1 champion Raikkonen.

"I lost a bit of speed and tried to fight back," Vettel said. "It was very close with Kimi in the end."