Two penalties from Cristiano Ronaldo have helped holders Portugal squeeze into the last 16 of the European Championship, after a 2-2 draw with France in a dramatic conclusion to Euro 2020 Group F on Thursday (NZ time).
World champions France won the group by one point from Germany in second with Portugal third, level on points with Germany.
Ronaldo edged his side in front from the penalty spot, becoming the first European in World Cup and Euros history to score a combined 20 goals across the two competitions.
France striker Karim Benzema scored twice to put his side ahead but Ronaldo equalised from the spot to become the joint top scorer in international soccer history.
Germany battled back to draw 2-2 with Hungary in Munich, eliminating the Hungarians, as Portugal held on in Budapest to book a last-16 clash with Belgium on June 28 in Seville. France will face either Ukraine or Switzerland in Bucharest on June 28.
A late Leon Goretzka goal salvaged a 2-2 draw for Germany against Hungary in a whip-saw contest that sets the Germans up for a Round of 16 match against England at Wembley.
Hungary looked like they would shock their hosts and send them out of the tournament, after Adam Szalai's diving header in the 11th minute to open the scoring.
Kai Havertz eventually drew Germany level in the 66th minute, only for Hungary to retake the lead seconds after the restart, as Andras Schaefer ran onto a pass and headed in.
Goretzka bagged the crucial equaliser in the 84th minute to send Germany through in second place behind France in Group F on four points.
The German pressure finally paid off in the 84th, when substitute Jamal Musiala cut the ball in the box and fellow substitute Goretzka drilled it home to avoid another tournament fiasco for the Germans and set up a mouth-watering clash with England.
Meanwhile, Spain crushed a hapless Slovakia 5-0 for their first win, setting up a last-16 clash against Croatia, after being set on their way by a calamitous own-goal from keeper Martin Dubravka.
Aymeric Laporte headed in a second goal on the stroke of halftime, before second-half goals from Pablo Sarabia, Ferran Torres and a Juraj Kucka own goal rounded off an emphatic win that saw them finish second in Group E - five points behind Sweden.
Luis Enrique's side will next meet Croatia in Copenhagen on Tuesday, while Slovakia head home.
In the other match of the day, Sweden winger Emil Forsberg scored a double including the second fastest strike in European Championship history, before Viktor Claesson's stoppage-time goal helped them seal a 3-2 win over Sweden to top Group E.
Sweden will next face Ukraine in a Round of 16 match in Glasgow on June 29.