After Portugal's 2-1 win over Holland in Kharkiv, another three points at Arena Lviv confirmed Germany as Group B winners with three victories while Portugal progress as runners-up from the so-called "Group of Death".
"The match was just as tough as we thought it would be," said Germanycoach Joachim Loew.
"We lacked the killer instinct in the first-half, which would have made it easier, and then Denmark scored.
"We knew we could have gone out if we had gone behind, so nerves crept in.
"We showed maturity in the second-half, but we can still improve."
The Germans will now play Friday's quarter-final against Group A runners-up Greece in Gdansk, their Euro 2012 base, while Portugal will play the Group A winners the Czech Republic in Warsaw on Thursday.
Lukas Podolski, who was making his 100th appearance for Germany, celebrated his century with the opening goal on 19 minutes which was cancelled out by a Michael Krohn-Dehli just five minutes later before Bender's late winner.
"Independent of the goal, that was my first start (for Germany), so it was something special," beamed Bender.
"We were trying to get that second goal, I just saw the goal in front of me and it was a bit lucky.
"I am not used to being in that position, but it felt good to be there."
Having made his debut in the 2-2 friendly draw with Poland last September, the 23-year-old Bender was making only his ninth appearance for Germany, while twin brother Sven, who plays for Borussia Dortmund, was cut from the squad.
Both coaches made only essential changes to their start line-ups.
Germany's Joachim Loew opted for Bayer Leverkusen's Bender at right-back for Bayern Munich's Jerome Boateng, who was suspended after picking up a yellow card in their 2-1 win over Holland last Wednesday.
Likewise, Denmark's Morten Olsen brought Jakob Poulsen into the midfield for veteran forward Dennis Rommedahl, who damaged his hamstring in their 3-2 defeat to Portugal.
The Germans started at pace and only a superb block by Denmark goalkeeper Stephan Andersen from a Thomas Mueller low drive on six minutes denied the Germans.
Germany got the break through when Mueller fired his pass across the Denmark goal and Gomez let the ball roll for man-of-the-match Podolski to drill his shot home on for his 44th international goal.
The Germans held the lead for five minutes before Bendtner headed back from a corner and Krohn-Dehli, who also scored in the Danes' shock 1-0 win over Holland, got his head to the ball before the German defence.
It was 1-1 at the break, but midfielder Jakub Poulson, in for hamstring injury-victim Rommedahl, clipped the post with his shot on 51 minutes.
The game's tempo dropped noticeably in the second-half with Germany's midfield star Mesut Ozil looking flat as the Danish defenders constantly thwarted the Germans.
Podolski was brought off with 25 minutes left as Leverkusen's Andre Schuerrle was given his chance and he soon tested Andersen with a shot.
With ten minutes to go, Germany counter-attacked at pace. Ozil squared for the grateful Bender and the right-back calmly slotted past Andersen to seal victory.
Kareena Kapoor Khan snapped with baby Taimur at mom Babita's house
Photos: Amruta Fadnavis at a fashion and lifestyle exhibition
Photos: Sushmita Sen stuns in a black dress with thigh-high slit
Photos: Bhumi Pednekar, Saiyami Kher at a film screening in Mumbai
Dreaded dons! Meet Bollywood's gangster brigade