Iceland set up a last-16 clash with England as substitute Ingvi Traustason’s last-gasp winner earned the Euro debutants a famous 2-1 win over Austria.
Republic of Ireland scored their own memorable 1-0 win over Italy and Belgium beat Sweden by the same score to both move into the last 16, ending the international career of Swedish legend Zlatan Ibrahimovic in defeat.
The Irish, Belgians, Iceland and Portugal join hosts France, Wales, Germany, Croatia, Italy, Switzerland, England, Poland, Spain, Slovakia, Northern Ireland and Hungary in the last 16.
The Republic will take on hosts France in Lyon on Sunday.
Ronaldo made a record 17th European Championship appearance against Hungary and twice rescued his side from an embarrassing early exit as surprise package Hungary took top place in Group F.
After disappointing performances against Iceland and Austria, Ronaldo came good just in time to set up a meeting with Croatia in Lens on Saturday.
Zoltan Gera smashed Hungary into an early lead before Ronaldo slipped in a pass to Nani to equalise before half-time.
Hungary captain Balazs Dzsudzsak twice threatened to cause a massive upset by sending Ronaldo crashing out early in the second period.
Dzsudzsak’s deflected free-kick put Hungary 2-1 up, but Ronaldo responded with a sumptuous backheel for his historic goal.
Just five minutes later another deflected Dzsudzsak effort restored Hungary’s lead.
Yet Ronaldo was not to be denied as a towering header moved him to within one goal of Michel Platini’s record mark of nine goals in Euros finals.
Traustason’s strike at the death ensured Iceland their first ever win in a major finals and second place in the group and a date with England in Nice.
Jon Dadi Bodvarsson swept Iceland into an 18th-minute lead at the Stade de France, with Austria paying dearly for Aleksandar Dragovic’s missed first-half penalty.
Substitute Alessandro Schoepf levelled for Austria on the hour, but Traustason’s 94th-minute strike condemned Marcel Koller’s side, highly-fancied to shine before the tournament, to a premature exit.
Robbie Brady’s header five minutes from time sparked wild scenes of celebration in Lille as Ireland ended a much-changed Italy’s 100 percent record at the tournament to set up an enticing last 16 meeting with Didier Deschamps’ French side.
It was Ireland’s first win over Italy in a competitive match since the 1994 World Cup in the United States.
There was no fairytale ending for Ibrahimovic who announced before the match that he would retire from international football when Sweden’s Euro campaign ends.
Ibrahimovic alluded to his rags to riches story brought up in a tough district in Malmo as he said good-bye.
“It’s a nice story because where I came from, a little..what people call the ghetto, and I made that country my country.”
“I hope we can find another player, not a Zlatan as I don’t think in a small country like Sweden you can find someone like that, he’s really unique,” said Sweden boss Erik Hamren.
Ibrahimovic did have the ball in the net midway through the second-half against the star-studded Belgians, but the goal was ruled out for a foul by Marcus Berg in the build-up.
Belgium had a series of chances to kill the game off with Romelu Lukaku particularly profligate.
With six minutes remaining, Radja Nainggolan’s arrowed drive into the far corner ended Swedish hopes to set up a last 16 clash with surprise package Hungary.