McLaren's Lewis Hamilton edged Felipe Massa on the final lap Saturday to take the pole position for the German Grand Prix.

Hamilton went around in 1 minute, 15.666 seconds on his last lap to beat the Ferrari driver by 0.193 seconds and start first on the grid for the third time this season.

"I knew I had it in me, I knew we had the pace," Hamilton said. "I'm really happy with it, I won't say there's anything I particularly have to improve on."

Hamilton dominated Friday's practice and is coming off a 68-second victory at the British GP that gave him the advantage in a three-way tie atop the Formula One standings. The Briton has the tiebreaker against Ferrari drivers Massa and Kimi Raikkonen, who also have 48 points.

McLaren has improved its car since last month's French GP, with Heikki Kovalainen leading the second row for Sunday's 67-lap race. The 26-year-old Finn recovered from an early driving error on his penultimate lap to post the third fastest time on his final chance.

"Just a little mistake in the last lap cost me a little time, but these things happen," Kovalainen said, adding that he had damaged the bottom of the car at the hairpin turn.

"I just lost the rear end and went wide. Maybe I was just trying to go too deep into the corner."

Jarno Trulli of Toyota fills the second row from fourth, ahead of two-time world champion Fernando Alonso in his Renault.

Massa was pleased to be back on the front row after a Silverstone performance marked by five spins and a 13th-place finish _ last of the drivers who managed to complete the rain-hit race.

"Tough, for sure very tight," the Brazilian said of the difference between main rivals McLaren and Ferrari. "The race tomorrow will be a big competition between all four cars and for sure that's very exciting, but we have to do everything right."

Defending world champion Raikkonen will start from sixth ahead of Robert Kubica of BMW Sauber. Kubica, who trails the leaders by two points, has struggled at Hockenheim all weekend.

"All weekend long, we have been struggling a bit to find a good setup for the car," Raikkonen said. "Clearly sixth place is not satisfying and tomorrow we won't be in for an easy time, but it's definitely not the end of the world."

Conditions improved from Friday when rain fell over the track in the morning before drying up slightly in the afternoon. Hamilton handled both sets of conditions with ease.

"I feel very happy with what we've done," the 23-year-old said.

No McLaren driver has won at Hockenheim since Mika Hakkinen 10 years ago, while Ferrari has five victories in Germany since then, the last coming with Michael Schumacher in 2006.

Red Bull's Mark Webber will start eighth ahead of Toro Rosso's Sebastian Vettel, with David Coulthard _ who will be replaced at Red Bull by Vettel next year _ starting 10th.

Nick Heidfeld, who trails F1's leaders by 12 points, will start 12th after driving off at the Spitzkehre turn on his lap at the end of the second session.

"I locked the rear wheels going into the rear hairpin and lost so much time that I aborted the lap," the German driver said.

(This version CORRECTS Heidfeld's points total in penultimate graf.))