Lars Bender spared Germany from a shock Euro 2012 exit with the winning goal in a 2-1 victory over Denmark, whose tournament ended tonight in Lviv.
The Bayer Leverkusen midfielder, playing as full-back for the national team, struck as Denmark were pushing for a goal which would have taken them through to the last eight at their opponents' expense, and just after Morten Olsen's side had seen a strong penalty appeal turned down.
Lukas Podolski put Germany in front in the 19th minute, but a goal from Michael Krohn-Dehli five minutes later lifted Denmark's spirits.
Germany controlled much of the game, but were nevertheless made to sweat as Denmark's belief and Portugal's 2-1 win over Holland ensured a tense finale which ended in their favour, clinching them top spot in Group A with a perfect record and a clash with Greece in Gdansk on Friday.
Germany coach Joachim Low made his first change of the tournament, replacing the suspended Jerome Boateng with Lars Bender, but he resisted the temptation to make further alterations to his winning side.
Niki Zimling was passed fit to play by Denmark coach Morten Olsen, while the injured Dennis Rommedahl's place was taken by Jakob Poulsen.
Low's side began with authority and the diligent Muller went close twice early on, but Stephan Andersen showed lightning reactions to deny his second attempt in the sixth minute.
Germany remained camped in the Denmark half, playing a patient yet expressive game which led to Podolski marking his 100th Germany appearance with a goal in the 19th minute.
Muller provided a low cross from the right-hand side of the penalty area which Mario Gomez flicked intelligently back to Podolski, who left nothing to chance with a powerful shot from seven yards out.
Germany's lead lasted only five minutes, though, before Krohn-Dehli's second goal of the tournament brought the Danes level.
He diverted Nicklas Bendtner's header past Manuel Neuer from six yards out from a well-worked corner after a positive reaction from the Danes to falling behind.
Towards the end of the first half, Podolski blazed a free-kick over the bar from the edge of the penalty area and Sami Khedira prodded a shot wide from 10 yards out as Denmark were again forced to defend.
Jakob Poulsen went within inches of putting Denmark in front five minutes into the second half when his shot grazed the outside of the left-hand post with Neuer beaten.
Low sent Schurrle on for Podolski midway through the second half and his first touch of the game brought an excellent one-handed save out of Andersen.
Neuer showed less sophistication in dealing with Zimling's distance effort in the 71st minute, conceding a corner as Denmark enjoyed another bright spell.
Five minutes later, Bendtner got in around the back and tried at full stretch to lift the ball over Neuer, but without success as he had his shirt pulled by Holger Badstuber.
One goal for Denmark was still required to send them through and send Germany home since Portugal had taken the lead against Holland, but just as Low's side were showing the first signs of tension, they regained the lead from an unlikely outlet.
Mesut Ozil's throughball was intended for Miroslav Klose, but it was too far in front of the Lazio striker but inviting for full-back Bender, who coolly took his first international goal in the 80th minute to take Germany through and knock Denmark out of Euro 2012.