A stoppage-time header from Niclas Fuellkrug rescued a 1-1 draw for Germany against Switzerland on Sunday in Frankfurt, ensuring the Euro hosts finish top of Group A.
The Swiss took the lead when Dan Ndoye scored from close range after 28 minutes to stun the home side.
Germany took a series of risks late in the hope of an equaliser and veteran striker Fuellkrug delivered, heading home in the second minute of stoppage time.
The result means Switzerland, rather than Germany, face a tougher last 16 assignment, setting up a potential meeting with holders Italy or 2018 World Cup finalists Croatia.
The Germans look set to face second place in England's Group C, which is currently Denmark.
"I think the equaliser was deserved, as was the group win. We threw a lot forward at the end," said Germany coach Julian Nagelsmann.
"The cross was perfect. That was a nice moment for us as a team, that could be decisive. That changes the situation," Fuellkrug told ARD.
Heading into the match the hosts were optimistic they had turned the corner after almost a decade of disappointment at major tournaments, with two World Cup group stage exits bookending a Euros last 16 elimination.
Led by an experienced midfield featuring captain Ilkay Gundogan and Toni Kroos, Germany beat both Scotland and Hungary in their first two matche.
Germany were however caught off guard by Switzerland's energy and failed to carve out many clear-cut chances.
Despite Fuellkrug's late rescue effort, Nagelsmann will have plenty to ponder after the stodgy performance.
Nagelsmann decided to play the same starting XI for the third straight game despite already having made sure of a last 16 place.
It was a decision he may regret when defender Jonathan Tah saw yellow, his second in the group stage, meaning he will miss Germany's first knockout game.
"The yellow card for Tah was unjustified, which is annoying. But we have enough quality to compensate for that," Nagelsmann said.
Pushed on by an optimistic and partisan home ground, Germany started brightly, carving out some half-chances after launching long balls over Switzerland's midfield press.
Robert Andrich looked to have given Germany the lead after 16 minutes when Yann Sommer made a meal of his long-range strike, which bounced past the goalkeeper and into the net.
The goal was however overturned with VAR finding Jamal Musiala had committed a foul in the lead-up.
The Swiss had been on the back foot early but took the lead on the 28-minute mark, taking advantage of some sloppy play from Musiala and Joshua Kimmich.
Musiala lost the ball in his own half, sending Switzerland on the break. Kimmich won but then let go of possession, allowing Remo Freuler to find Ndoye who stuck out a leg and booted the ball into the net.
It was the first time the hosts had trailed this tournament and the goal seemed to rattle Germany, who were increasingly hesitant in closing out the first half.
Germany went on the attack in the second half as Nagelsmann made several offensive changes but the hosts had few clear chances against a Swiss side doggedly protecting their lead.
Man City defender Manuel Akanji stretched out to block Kimmich at point-black range with 20 minutes remaining.
Nagelsmann brought Fuellkrug from the bench with 14 minutes remaining and the Borussia Dortmund striker stepped up to the plate, heading in a cross from David Raum to send Germany back to the top of the group.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ