NUERBURGRING, Germany — Lewis Hamilton and his Mercedes earned the pole position for Sunday's German Grand Prix, edging Red Bull's three-time defending Formula One champion Sebastian Vettel.

Hamilton's second consecutive pole and third of the season made up for the disappointment of seeing the second Mercedes driver, Nico Rosberg, knocked down to 11th at the end of the second qualifying session.

Hamilton set the fastest qualifying time Saturday of 1 minute, 29.398 seconds. Vettel had dominated the last two practice sessions but ended up .103 seconds behind Hamilton, who gained his 29th career pole after his team overcame problems with the car during the last two practice sessions, which Hamilton called "disasters."

"It was even worse this morning. I was a good eight tenths of a second off, and I wasn't comfortable with the car at all," said Hamilton, who has often criticized his car before races.

"So we went back into the truck, analyzed everything, put in a lot of hard work ... It's a privilege to drive for this team, they've great history, so I'm proud to be able to get pole for them, but there are no points today. They come tomorrow," Hamilton said.

He is still winless since joining Mercedes this season.

Mercedes came into the race with fives poles in the previous six GPs but has struggled to maintain the momentum in racing conditions. Hamilton held the pole at the British Grand Prix last week but had an early puncture and finished fourth.

Marc Webber in the second Red Bull was third in qualifying, with the Lotus pair of Kimi Raikkonen and Romain Grosjean next.

Daniel Ricciardo of Toro Rosso was sixth, Felipe Massa of Ferrari seventh and his teammate Fernando Alonso eighth.

Rosberg, who won two of the last three races, was sitting second midway through the second qualifying session and his team left him in the garage, apparently believing his time was good enough to put him into the top 10 for the third and decisive session.

But Raikkonen led a charge of late efforts and Rosberg watched from the garage as he was eliminated.

"It was quite a shock," Rosberg said. "I didn't see it coming ... I thought I would be easily on the front row today."

Many leading drivers had threatened to pull out of Sunday's race if tire blowouts that plagued last week's British GP persisted.

Supplier Pirelli made changes and the tires have held, reducing the risk of a pullout.

Vettel said Pirelli appeared to have done a good job and did not think there would be any reason to pull out of the race.

"I am confident there will be no such problems," Vettel said.

Vettel said he was struggling "to get it together" in the first sector of the circuit and that the tail wind had been a factor.

"It was quite close, and I tried everything I had. But we are much closer to them here than we were in Silverstone. We have made some progress and are confident for tomorrow.

"We've done our homework and now it's up to us. We are on the front row, which wasn't quite enough for pole position, but I am looking forward to tomorrow," said Vettel, who is seeking his first win on home soil.

Vettel holds a 21-point lead over Alonso in drivers' standings after eight of 19 races.