Cristiano Ronaldo produced a stunning performance to keep Portugal in Euro 2016 with a 3-3 draw against Hungary in Lyon.
Ronaldo, who made a record 17th European Championship appearance in the match, set up Nani for Portugal's first and then scored twice in the second half to become the first player to score in four different European Championships.
Balazs Dzsudzsak, meanwhile, scored a brace of his own for Hungary, who led three times during the match and clinched top spot in Group F.
Portugal finish third and face Croatia in the round of 16 on Saturday, while Hungary take on the runners-up from Group E on Sunday.
Zlatan Ibrahimovic's international career is over after Sweden exited the competition following a 1-0 defeat by Belgium in Nice.
The star striker's announcement that the tournament would be his last dominated the build-up to the game, with Ibrahimovic saying in typically understated fashion: "To finish with a disappointment -- never.''
But that was exactly what transpired as Radja Nainggolan's superb late goal earned Belgium victory.
Marc Wilmots' team needed only a point to secure second place behind Italy in Group E and will face Hungary in the last 16 on June 26 in Toulouse.
Iceland advanced in their first-ever European Championship with a thrilling 2-1 defeat of Austria in Paris.
Jon Dadi Bodvarsson and Arnor Traustason scored the goals as the result ensured the tiny island nation a runners-up finish in Group F at the Stade de France on Wednesday, continuing their improbable Euro 2016 journey.
The win, coupled with Portugal and Hungary's draw, sets a round of 16 date with England.
Republic of Ireland scored in the 85th minute to secure a 1-0 victory over Italy and book a round-of-16 meeting with hosts France.
Robbie Brady headed home the only goal of the game as Ireland sealed progress after finishing third in Group E with four points.
The result means Ireland will take on France in Lyon on Sunday -- their first meeting with Les Bleus since the controversial 2010 World Cup qualifier that saw them controversially defeated as the result of a Thierry Henry handball.