Cristiano Ronaldo equalled the men's all-time international goalscoring record as defending champions Portugal drew with France to qualify for the last 16 of Euro 2020 as one of the best third-placed teams.
Ronaldo scored his 108th and 109th goals, both from the penalty spot, to equal Ali Daei's record set with Iran between 1993 and 2006.
They came either side of half-time but were not enough to give Portugal victory as striker Karim Benzema broke a six-year goal drought with France to score twice and ensure Les Bleus topped the group.
On a frantic evening, the four teams in Group F changed positions frequently, with Portugal looking set to face England in the next round before Germany's dramatic late equaliser bumped them from fourth to second and eliminated Hungary.
Ronaldo gave Portugal the lead after Hugo Lloris followed through on Danilo as he attempted to punch away a cross, before Benzema equalised on the brink of half-time after Nelson Semedo was adjudged to have blocked off Kylian Mbappe's run in the box.
Benzema scored a second immediately after the restart following a stunning pass from Manchester United's Paul Pogba but Ronaldo drew Portugal level when he won and converted a second penalty 13 minutes later.
The draw in Munich meant Portugal finished in third place based on a head-to-head record, while France topped the group, a point ahead of Germany.
Ronaldo-inspired Portugal show real threat
The match was teed up as a battle of giants and Ronaldo produced the goods as one of the biggest.
His first goal saw him become the outright European top scorer at major tournaments with 20 - overtaking former Germany striker Miroslav Klose - and his second equalled Daei's record.
He now has 48 goals in his past 45 matches for Portugal and, with five goals in three matches so far at Euro 2020, he leads the race for the Golden Boot.
Portugal face another tough test in the next round, with world number one side Belgium waiting in the last 16, but they showed their threat in this draw with world champions France.
Ronaldo's ability to score when it matters was demonstrated once again, while experienced defender Pepe showed his guile at the back to thwart Mbappe.
Goalkeeper Rui Patricio also made a vital contribution - brilliantly denying Pogba from long range with a fingertip save, before recovering to palm away Antoine Griezmann's rebound effort in the second half.
Portugal quietly went through the rounds in 2016 before lifting the title and despite a sometimes nervous night in Budapest they remain a threat as the tournament moves into the knockout stages.
France's Benzema earns Ronaldo's respect
If Ronaldo stole the show in his usual fashion, it was former Real Madrid team-mate Benzema who denied the defending champions a place at the top of the table.
Benzema, who last scored for France in October 2015, showed composure to smash in the equaliser from the spot in the first half - even receiving a pat on the back from Ronaldo as he returned to the centre circle.
The pair hugged at half-time as they walked off the pitch deep in conversation but Benzema showed no mercy when the teams returned from the break, sliding home France's second from Pogba's inch-perfect pass.
The teams were level again after Ronaldo chipped it on to the outstretched arm of Jules Kounde to win Portugal's second penalty but France could still have won it later on when Pogba and Griezmann forced the smart double-save from Patricio.
Mbappe was a nuisance without scoring again, Pogba produced moments of quality and in Benzema, France have a world-class striker.
They take on Switzerland in Bucharest on Monday and will remain one of the hot favourites for the competition.