Three-time champions Germany were shaky but advanced to the Euro 2012 quarterfinals with a 2-1 victory on Sunday over Denmark, who were eliminated from the championship.
Celebrating his 100th cap, Lukas Podolski pushed the Germans ahead in the 19th minute but watched as Michael Krohn-Dehli tallied his second goal of the tournament to equalise in the 24th minute.
But Lars Bender, who was replacing the suspended defender Jerome Boateng, gave Germany the victory with his goal in the 80th minute at Lviv’s Arena.
Germany took group B honors with a perfect nine points while Denmark were eliminated from the tournament with three points.
Portugal knocked off the Netherlands 2-1 for six points while the Netherlands went home without a point in last point.
In the quarters, Germany will take on Greece on Friday in Gdansk, Poland, and Portugal face the Czech Republic on Thursday in Warsaw.
Both Germany and Denmark made one change to their line-ups withBender replacing Boateng in the German backline and Jakob Poulsen filling in for the injured Dennis Rommedahl up front for the Danes.
Germany started with some fine chances but Thomas Mueller fired over the bar in the second minute and had his shot from six yards saved superbly by Danish keeper Stephan Andersen in the sixth minute.
The Germans took the lead 1-0 in the 19th minute after a throw-in as Mueller turned in the box and passed to Mario Gomez, whose back-heel found Podolski for a blast with his weaker right foot from close range -- a great gift for his 100th cap which brought him man of the match honors.
It was Podolski’s first goal of the tournament -- and Germany’s first not scored by Gomez.
But the Danes did not let Podolski and the Germans celebrate long, grabbing the equaliser 1-1 on a superb set piece in the 24th minute.
A corner from the right side went left of goal to Nicklas Bendtner, who headed back into the middle where Krohn-Dehli headed past Manuel Neuer from seven yards.
Germany were in fine position in the 37th minute with a free kick at the very edge of the box but Podolski thundered his left foot blast into the skies of Lviv. And Sami Khedira poked his attempt just wide right in the 41st minute for the Germans.
The game remained an even match and it was the Danes who were close first after the break as Bendtner fed Poulsen for a strike from just outside the area which grazed off the left post in the 51st minute.
Germany finally created another chance after 67 minutes as Khedira fed substitute Andre Schuerrle, whose shot was blocked away by Andersen.
The Danes were close to punishing the Germans for their lack of wherewithal as Neuer needed a fine save on Bendtner’s looping shot in the 76th minute.
Knowing a goal by Denmark would mean an unexpected early exit, Germany felt a huge sense of liberation with 10 minutes to play by grabbing the winner 2-1.
Mesut Oezil’s pass on the counter attack was intended for Miroslav Klose, who had slipped. But Bender raced forward as well and kept his nerves in beating Andersen for his first international goal.