Right-back Lars Bender's first international goal won the game for Joachim Loew's side on the night with 10 minutes remaining after Michael Krohn-Dehli had cancelled out Lukas Podolski's early opener.
There were some appeals for a Denmark penalty with 15 minutes remaining when Nicklas Bendtner appeared to have his shirt tugged by Holger Badstuber but referee Carlos Velasco Carballo - usually so liberal with his cards - did not take any action.
On an evening in which possession of the much-coveted second place in the group changed hands four times but failed to deliver the nail-biting finish the many group permutations had promised, a combination of Danish defeat in Lviv and Portugal's 2-1 win over Netherlands in Kharkiv saw the Danes eliminated by finishing third in the group on three points.
As group winners with nine points, Germany will play Greece in Gdansk on Friday June 22, while Portugal will face Czech Republic in Warsaw a day earlier after they finished second on six points. The Dutch go home with no points.
The victory for Germany means they have won every single competitive fixture since they lost 1-0 to Spain in the semi-finals of the 2010 World Cup, having come through the qualifying phase for this competition with 10 wins out of 10. What's more, they have opened the scoring in each of those 13 subsequent games.
As expected, Germany's pace and attacking thrust saw them have the best of the opening exchanges, with Thomas Mueller firing one half-volleyed shot over the bar before sending a tame side-footed effort trickling to the keeper from six yards.
Podolski opened the scoring for Germany, putting Portugal in the top two despite Rafael van der Vaart's opening goal for Netherlands in Kharkiv.
Podolski, who turned 27 years of age a fortnight ago, became the youngest European to reach 100 international caps, and he marked the occasion with his 44th goal for Germany.
The forward, who will be lining up for Arsenal next season, gave the Premier League a taste of what to expect on 19 minutes when he pounced on to a low cross from the right and fired home from 10 yards. Denmark keeper Stephan Andersen got both hands to the strike, but the power was enough for it to hit the net.
That goal had Portugal poised to go through alongside Germany by virtue of their superior head-to-head record with the rest of the group, but it was far from the final twist in the tale.
Germany's lead lasted just five minutes before Krohn-Dehli levelled up for the Danes. The Brondby man, who scored the winner in the 1-0 win over Netherlands, was the most alert when Bendtner nodded a corner back across goal, and the five-foot-seven midfielder glanced his own header past Manuel Neuer.
Denmark were now set to progress as the outright second-placed side, but there was more drama before the half-hour mark as Cristiano Ronaldo's goal was sending Portugal through thanks to their 3-2 win over Denmark last time out.
Podolski blazed over a free-kick from the edge of the box and Sami Khedira prodded an effort wide, but the score remained level at half-time with Denmark on their way out.
Morten Olsen's side made a brief stab of a fightback after the break, with Jakob Poulsen's strike shaving the outside of the post after good hold-up play by Bendtner, but in truth that was as close as they got.
Andersen was forced into a regulation save from Bastian Schweinsteiger low to his left, but once news filtered through that Ronaldo had scored his and Portugal's second in Kharkiv there looked no way back for Denmark - despite the fact that scoring one more of their own would put them through and Germany out.
Some thought they would have that chance when Bendtner was at full stretch to meet a floated ball into the box and Badstuber appeared to have a handful of the Arsenal striker's shirt. However, Spanish official Velasco - whose two red cards in the opening match of the tournament took his tally for the season to 17 and who averaged 7.5 bookings in La Liga last term - deemed the incident unworthy of his involvement.
On 80 minutes it was all over and Germany were confirmed as progressing with a 100 per cent record. Mesut Ozil's pass was too far ahead of substitute Miroslav Klose, but it ran ideally for Bender to meet on the run and sidefoot a cool finish past Andersen to open his international account on his ninth senior appearance.