Substitute Lars Bender netted the winner as Germany topped Group B with a 2-1 win over Denmark.
Lukas Podolski scored the opening goal in his 100th appearance for the Euro 2012 favorites, before Michael Krohn-Dehli equalised. Bender, however, came on from the bench to seal top spot for the Germans ten minutes from time.
Germany will now take on Greece in the quarterfinals, while Denmark are knocked out. Portugal qualified for the quarterfinals courtesy their Cristiano Ronaldo-inspired 2-1 win over the Netherlands. Portugal face Czech Republic in the other quarterfinal.
Germany controlled possession for much of the game and was duly rewarded in the 19th minute. Thomas Muller played a low cross from the right, which was nicely directed to the path of Podolski by Gomez. The soon-to-be Arsenal forward, smashed the ball with his right foot past goalkeeper Stephan Andersen.
However, Denmark, like they have throughout the tournament, showed their fighting spirit and got back into the game in the 25th minute. Krohn-Dehli, who scored the opening goal for the Danes in their shock 1-0 win over the Dutch, guided the ball past goalkeeper Manuel Neuer off a well-worked corner.
Denmark kept searching for the winner, which would have seen them through to the next round at the expense of Germany, but were hit on the counter, with Bender capitalising on a mistake from the Dane defense to slot it past the goalkeeper.
Germany coach Joachim Low, said he was confident his side would come through, despite some nervous moments in the finals 20 minutes. "I had a plan. Of course I had considered what would have happened if Denmark had in some way suddenly scored a goal but I never had that feeling.
"I was pretty relaxed because it doesn't get you anywhere when you panic. Bastian Schweinsteiger and Sami Khedira were always in control and I just had the feeling we would score.
"Denmark played with a stoic calmness and it seemed like they could not care less.
"I never had the feeling that Denmark were playing to win it. They wanted to keep the result, were happy with the draw and then maybe they would get a free-kick or corner that they could take advantage of, but they did not attack much.
"They sat back a lot, even though they had to win. They had one or two good chances, but no more than that, and I think in the second half we did a decent job given the pressure.
"Maybe had we played Holland or Portugal (in the final group game), they would have done more for a win than Denmark did."
Denmark coach Morten Olsen defended his side's performance and refuted Low's claims of negativity. "If you try to put them under pressure, then you can get punished quickly.
"One-one was a good result for us because then you just need a lucky punch maybe with a set-piece, but if you gamble too much, they can hit you quickly.
"We are disappointed not to have gone through, but this team has a future.
"Compliments to all of our players -- they played a great tournament and it is only minor details which make a difference."