Cristiano Ronaldo equalled Ali Daei's all-time international goalscoring record as he held his nerve to haul Portugal to a 2-2 draw with France and into the knockout rounds of Euro 2020.
Ronaldo scored the first of three penalties awarded by Spanish referee Mateu Lahoz at the Puskas Arena, although his old Real Madrid strike partner Karim Benzema levelled from the spot and put the world champions ahead at the start of the second half.
At that stage, the holders were staring at elimination as Les Blues eyed a measure of revenge for their Euro 2016 final defeat, but Ronaldo stepped up again at his country's hour of need when Jules Kounde was penalised for handball.
Having already overhauled Miroslav Klose – whose countrymen Germany flirted with disaster before salvaging a 2-2 draw against Hungary in Munich – to become the leading combined scorer at World Cups and European Championships combined, Ronaldo beat Hugo Lloris again to pull level with the mark set by Iran's Daei – one that has long been in the five-time Ballon d'Or winner's sights.
Paul Pobga unlocked the Portugal defence with a glorious 16th-minute throughball, although Kylian Mbappe's finish was not of the same standard and Rui Patricio saved.
Opposite number Hugo Lloris did not cover himself in glory when he rashly tried to punch Joao Moutinho's free-kick and clattered into Danilo Pereira. The France captain was cautioned and unable to atone as Ronaldo sent him the wrong way from the spot.
He was quickly followed into the book by Antoine Griezmann and Lucas Hernandez as Lahoz placed himself at the centre of the contest, and the official handed France a lifeline as he penalised Nelson Semedo for blocking off Mbappe and Benzema dispatched from 12 yards.
Another delicious Pogba pass completed a swift turnaround, as Benzema got away from Ruben Dias to coolly slot home two minutes into the second half.
Ronaldo almost found an instant response when he met Raphael Guerreiro's and he levelled with an hour played, Lahoz pointing to the spot once more when Kounde handled the Juventus star's delivery.
Pogba remained the game's outstanding player and Rui Patricio clawed out a stunning 25-yard effort from the Manchester United man before springing up to sharply deny Griezmann on the follow-up.
In stoppage time, Lahoz passed up the chance to give the fourth spot-kick of a fairly remarkable personal outing and a VAR check spared Bruno Fernandes for a clumsy challenge on fellow substitute Kingsley Coman.
What does it mean? France top 'group of death' as Portugal and Germany live to fight another day
The value of Benzema's brace was born out in France topping the group as the only undefeated team, earning a comparatively favourable tie against Switzerland in Bucharest. By contrast, Portugal travel to Seville to take on the world's number-one ranked side Belgium and Germany must face England at Wembley.
France have an amazing record against Portugal, and can potentially knock Portugal out with a win! Extra motivations then for Les Bleus!
The team news is in! No Bruno Fernandes for Portugal tonight! He starts on the bench!
A crunch game, plenty for Portugal to do tonight! Can they get the result?
This french legend will be hoping for a big win tonight!
Happy birthday Zinedine Zidane! 🎂— beIN SPORTS (@beINSPORTS_EN) June 23, 2021
A Real Madrid icon as a player and a manager! 🏆
Only one goal to share here. The finest volley you will EVER see in a #UCL final.
The technique is just out of this world! 🙌#beINUCLpic.twitter.com/xwtnMHb8DY
Likewise a few Portugal fans are out and about in Budapest!
The French are out in force in Budapest before the game!
Good evening! We have a blockbuster tie to finish off Group F and there is plenty on the line! Portugal needs a result already qualified to guarantee a place in the round of sixteen. Join me for all the build-up, team news and live commentary from the game.