German defender Lars Bender scored a late goal to give Germany a workmanlike 2-1 win over Denmark tonight and secure top spot in Euro 2012 Group B.
Germany, who looked comfortable throughout and finished with the maximum nine points, will play Greece, runners-up in Group A, in the quarter-finals.
Denmark failed to qualify, losing out to Portugal who beat the Netherlands 2-1 and will meet the Czech Republic in the last eight.
Bender, replacing the suspended Jerome Boateng in the starting lineup, benefited from poor Danish defending to run on to a pass from Mesut Ozil and calmly slot home from close range in the 80th minute.
"It is something special for me," Bender said. "It's a wonderful present to come in top in this group.
"There were positive spirits out there tonight. We were focused on getting a goal. It was a bit of luck that the ball came to me but you don't think a lot about it, you just shoot it in."
Lukas Podolski scored his 44th international goal in his 100th match in the 19th minute, smacking the ball into the net after a cross hit the boot of team mate Mario Gomez fell perfectly into his path some 10 metres out.
Michael Krohn-Dehli levelled for Denmark in the 24th minute with his second goal of the tournament, nodding in unmarked after German defender Mats Hummels failed to cut out a header into the danger zone from Nicklas Bendtner.
The Danes, who needed to win to go through, could have taken the lead in the 51st minute but Jakob Poulsen shaved the post from 10 metres after great set-up play from Bendtner, who was one of Denmark's best players in the tournament.
Denmark did little else to threaten the German goal and could easily have lost had Podolski, Thomas Mueller and in particular Sami Khedira converted presentable first-half chances.
Man-of-the-match Podolski, 27, became the youngest European player to win 100 caps for his country.
Germany had the better of the first half and could have scored in the sixth minute when Mueller scuffed a shot from close range which keeper Stephan Andersen had to scramble to save.
"The coach put his faith in me and I was relatively relaxed about it all," Bender said.
"I'm happy that I got to play tonight and crowned it was a goal is a great present for me. The important thing is that the team continues playing successfully and I'm happy to play."