Hamilton took a four-point lead after a dominant weekend
Lewis Hamilton moved into a four-point championship lead after a brilliant victory in the German Grand Prix.
The McLaren driver led from the start but a comfortable win was put in doubt by his team's decision not to pit him during a safety car period.
Hamilton dropped to fifth when he did finally stop under racing conditions.
But team-mate Heikki Kovalainen let the Englishman by, and Hamilton was able to catch and pass Ferrari's Felipe Massa and then Renault's Nelson Piquet.
Team boss Ron Dennis admitted that McLaren had "got it a bit wrong".
He said the team did not expect the safety car to stay out as long as it did following a heavy accident to Toyota's Timo Glock, who crashed into the pit wall following what appeared to be a rear suspension failure.
McLaren thought Hamilton would have enough laps after the re-start to build a lead that was big enough to maintain his position.
The safer - and more sensible - option would have been to pit Hamilton during the safety car period - as nearly all the other leading teams did with their drivers.
The team opted for me to stay out but I think I needed a 23-second gap in about seven laps so I don't know how that would have worked out
As it turned out, Hamilton was only 10 seconds ahead of Massa's fourth-placed Ferrari when he pitted on lap 50, about half what he would have needed to stay ahead.
But Hamilton quickly caught Massa, and passed the Ferrari on lap 57 when the Brazilian made it too easy for the McLaren driver.
Massa appeared to have the inside line into the hairpin covered, but he then went back to the outside, giving Hamilton the chance to take the position.
Hamilton then quickly closed the two-second gap to Piquet and passed him in the same place, and in similar fashion, on lap 60.
"I would have preferred a comfortable afternoon out in front," Hamilton said.
"We had got off to a good start and had two decent stints and the team opted for me to stay out but I think I needed a 23-second gap in about seven laps so I don't know how that would have worked out.
"For sure we will learn from this and move on. But we still had the best and quickest car this weekend and we came out on top.
"With Felipe, I saw I was a lot quicker than him.
Piquet took a surprise second place for Renault
"I knew I only had a small window to get past him because of my tyres but the great thing about this track is that you can follow people.
"So I got quite close to him - he matched my speed down my straight - it was difficult to get past him but he gave me plenty of room.
"I thought my work was done but I still had to get past Nelson. He put on a good battle but again it was very fair."
Piquet found himself in the lead because he was on a one-stop strategy, and he had just made his pit stop when the safety car was deployed after Glock's crash on lap 36.
He took the lead when first Hamilton and then BMW Sauber's Nick Heidfeld stopped.
But the novice was in no position to hold off the charging Hamilton in a much faster car.
Piquet was, however, more than capable of holding off Massa, who was unable to catch the Renault before the end of the race.
It was Renault's first podium finish since the Japanese Grand Prix last year, and it was ironic that it should come from a man who has been overshadowed by team-mate Fernando Alonso this year.
By contrast, Alonso had a race to forget - he was stuck behind slower cars for the entire afternoon, but none of his overtaking attempts came off, and several of them ended with him being outfoxed by rivals and losing a place to the car behind him.
The Spaniard also spun late in the race, losing a position he had just taken from Nico Rosberg's Williams, and finished in 11th place.
It was not a performance to impress the bosses at Ferrari, to whom speculation in the paddock continues to link the double world champion.
But if there was any consolation it was that neither of the Ferrari drivers had good weekends.
Massa blamed his inability to hold off Hamilton on his car's lack of competitiveness.
"I just did not have the pace," he said. " I was on the hard tyres because the soft was so difficult to drive. Stability was difficult, too, for me, and I think I had a little bit of a problem on the brakes as well.
"I lost a lot of performance. So I didn't have the car to fight. I tried, but it was not possible."
Hamilton passed Massa and Piquet in the closing laps to secure victory
While Massa may have erred in letting Hamilton by, he at least outstripped team-mate Kimi Raikkonen, who was uncompetitive all weekend.
After qualifying sixth, the Finn never looked like being a factor in the race, and he finished in the same place.
He is now seven points behind Hamilton as the world championship battle continues to see-saw from race to race.
BMW benefited from their decision not to pit Heidfeld under the safety as the German took fourth place ahead of Kovalainen.
Heidfeld had been out of the top 10 for much of the first part of the race.
Kubica was running fourth in the first part of the race, having passed Alonso and Raikkonen on the first lap, but he lost out to the Finn once racing resumed after the safety car.
Toyota said Glock was not injured but would be kept in hospital overnight as part of standard procedure after a precautionary check-up.
German Grand Prix results:
1 Lewis Hamilton (GB) McLaren-Mercedes one hour 31 minutes 20.874 seconds
2 Nelson Piquet Jr (Brz) Renault at 5.586 seconds
3 Felipe Massa (Brz) Ferrari at 9.339
4 Nick Heidfeld (Ger) BMW Sauber at 9.825
5 Heikki Kovalainen (Fin) McLaren-Mercedes at 12.411
6 Kimi Raikkonen (Fin) Ferrari at 14.483
7 Robert Kubica (Pol) BMW Sauber at 22.603
8 Sebastian Vettel (Ger) Toro Rosso-Ferrari at 33.282
9 Jarno Trulli (Ita) Toyota at 37.199
10 Nico Rosberg (Ger) Williams-Toyota at 37.658
11 Fernando Alonso (Spa) Renault at 38.625
12 Sebastien Bourdais (Fra) Toro Rosso-Ferrari at 39.111
13 David Coulthard (GB) Red Bull-Renault at 54.971
14 Kazuki Nakajima (Jpn) Williams-Toyota at 1:00.003
15 Adrian Sutil (Ger) Force India-Ferrari at 1:09.488
16 Giancarlo Fisichella* (Ita) Force India-Ferrari at 1:24.093
17 Jenson Button (Gbr) Honda one lap behind
R Rubens Barrichello (Brz) Honda 50 laps completed
R Mark Webber (Aus) Red Bull-Renault 40 laps
R Timo Glock (Ger) Toyota 35 laps completed
* Fisichella penalised 25 seconds for safety car infringement
Fastest lap: Heidfeld, 1:15.987, lap 52
Key: R = retired