Lewis Hamilton of Mercedes on Saturday edged out defending champion and season leader Sebastian Vettel to claim his fourth pole position of the season for Sunday's Hungarian Grand Prix.

Hamilton pulled out a best lap of 1min 19.388sec to land his third straight pole and the 30th of his career with Red Bull's Vettel timing 1.19.426.

Frenchman Romain Grosjean in a Lotus was third fastest to take his place on the second row of the grid. It was 2008 champion Hamilton's fourth pole at the Hungaroring circuit.

The 28-year-old Briton pulled off his fastest lap right at the conclusion of a closely-fought session, having battled handling and balance problems on Friday with the new Pirelli tyres.

Lewis did an exceptional job today - you have to hand it to him

Sebastian Vettel, Red Bull reigning champion

Hamilton's latest gambit lifted him beyond five-time champion Argentine Juan Manuel Fangio to a career total of 30 poles. He himself appeared surprised at the feat after he squeezed ahead of defending triple world champion German Sebastian Vettel at the front of the grid.

"Are we on pole?" he asked on his slowing down lap.

"Yeah - and we are as surprised as you, mate!" responded his race engineer.

"Brilliant job, Lewis," said team chief Ross Brawn.

"There wasn't much in it," said Vettel, who nonetheless praised Hamilton.

"Lewis did an exceptional job today - you have to hand it to him."

But the German, seeking a first career win in Hungary, stressed: "I am still in a good position for tomorrow and we have a good car for the race."

German Nico Rosberg in the second Mercedes was fourth fastest ahead of two-time champion Spaniard Fernando Alonso of Ferrari, who outpaced 2007 champion Finn Kimi Raikkonen in the second Lotus, Brazilian Felipe Massa in the second Ferrari and Australian Daniel Ricciardo of Toro Rosso.

Mexican Sergio Perez recovered from a crash in morning practice to take ninth place for McLaren ahead of Australian Mark Webber who sat out the session for Red Bull after yet another KERS failure.