Germany's Sami Khedira, center, celebrates with teammate Germany's Per Mertesacker after scoring his side's third goal during the World Cup third-place soccer match between Germany and Uruguay at Nelson Mandela Bay Stadium in Port Elizabeth, South Africa, Saturday, July 10, 2010. Germany won 3-2.
But the Germans had to survive a final-second free kick by Uruguay striker Diego Forlan, who scored five goals in the tournament, from just outside the penalty area. The shot ricocheted off the crossbar, and the whistle sounded.
This marks Germany's second straight third place finish in the World Cup.
Khedira's header after the Uruguay defense failed to clear a corner kick by Mesut Oezil ended Uruguay's hopes of beating Germany for the first time in 82 years.
"We had hoped for more, and we did everything for it," Khedira said. "This was some kind of final and we did everything for it.
"We have a young team and set an exclamation mark here and can reach more."
Uruguay came from behind to lead 2-1 when Forlan brilliantly volleyed in Egidio Arevalo's 51st-minute cross for his fifth goal of the tournament.
Germany defender Marcell Jansen tied it five minutes later with a header after goalkeeper Fernando Muslera misjudged a cross.
In the dying moments, on a rain soaked pitch, Uruguay had one more opportunity. But Forlan, who has been especially dangerous on free kicks, hit the bar.
"Obviously it's something spectacular to be among the top four," said Forlan. "If someone would've asked us at the beginning, we would've liked it. It's something positive."
Thomas Mueller opened the scoring for Germany in the 18th minute, also his fifth goal at the World Cup. Edinson Cavani equalized for Uruguay in the 28th when he slid a shot past goalkeeper Hans Joerg Butt.
Miroslav Klose's aching back prevented him from playing for Germany and he finished the tournament with four goals and 14 for his career. He is one goal shy of Brazilian forward Ronaldo's World Cup record and, at 32, doesn't expect to play in 2014 in Brazil.
Germany coach Joachim Loew was forced to make five changes to his team. Defender Philipp Lahm and forward Lukas Podolski were out with the flu. Loew also has the flu but was on the bench. Backup striker Mario Gomez also has the flu.
In an action-packed match, Butt made two good saves on Luis Suarez and Forlan after his team's second goal. The 36-year-old veteran, who was the third-string goalkeeper in 2002, got his World Cup debut replacing Manuel Neuer.
Suarez returned from a one-game suspension for a handball on the goal line against Ghana in the quarterfinals. He saved a goal, Ghana missed the ensuing penalty kick on the final play of extra time, then Uruguay won the shootout.