The Danes were eliminated after the two teams finished their Group B campaigns.
Lukas Podolski opened the scoring for Germany in the 19th minute and Lars Bender slotted home the winner in the 80th after Michael Krohn-Dehli had equalized for Denmark in the first half.
”It’s absolutely a day of joy,” Bender said. ”I’ll be thinking back to this day a long, long time. We have a positive spirit in the team.”
Germany played without flair, but controlled possession and were never really challenged by the Danes, who go home after stunning the Netherlands in the first match but losing to Portugal in the second.
”We can be satisfied with our effort but not with the result,” Denmark midfielder William Kvist said. ”I think we proved that we can play against the big teams. We won (against the Netherlands) and we didn’t lose big. We showed that we can play against the best.”
Germany seized the initiative from the kickoff and came close twice before Podolski, playing his 100th international match, scored his first goal of the tournament.
Mario Gomez set him up with a deft backheel touch following Thomas Mueller’s low cross from the right flank.
Denmark replied just five minutes later with Krohn-Dehli heading in the equalizer from a set piece that stunned the German defense. A corner found Nicklas Bendtner who headed the ball into the area where Krohn-Dehli nodded home his second goal at Euro 2012.
Jakob Poulsen missed a chance to put Denmark in the driver’s seat at the start of the second half when his shot grazed the outside of German goalkeeper Manuel Neuer’s right post.
After that scare, the Germans were firmly in charge and denied Denmark any real chance of getting back into the game.
Coach Morten Olsen’s men were already looking tired when Bender, replacing suspended right back Jerome Boateng, picked up a pass from Mesut Oezil and made it 2-1.
It was the first competitive match between the two countries since the 1992 European Championship final, when the Danes stunned the Germans with a 2-0 win to become champions.
Hoping for another upset, Olsen changed his lineup by moving playmaker Christian Eriksen to the right flank, replacing injured winger Dennis Rommedahl in a five-man midfield.
But the move had little effect as Phillip Lahm effectively closed down the talented 20-year-old, who leaves Euro 2012 without fulfilling expectations of an international breakthrough.
Germany finished top of the group with a perfect record of three wins and now faces Euro 2004 champion Greece on Friday in Gdansk.
Denmark: Stephan Andersen, Lars Jacobsen, Simn Kjaer, Daniel Agger, Simon Poulsen, William Kvist, Christian Eriksen, Jakob Poulsen (Tobias Mikkelsen, 82), Niki Zimling (Christian Poulsen, 78), Michael Krohn-Dehli, Nicklas Bendtner.
Germany: Manuel Neuer, Lars Bender, Mats Hummels, Holger Badstuber, Philipp Lahm, Thomas Mueller (Toni Kroos, 84), Sami Khedira, Bastian Schweinsteiger, Mesut Oezil, Lukas Podolski (Andre Schuerrle, 64) Mario Gomez (Miroslav Klose, 74).