Lionel Messi and Argentina needed every minute of stoppage time to avoid a stunning World Cup elimination Monday, coming from two goals down in the final 11 minutes to defeat Egypt 3-2 in a breathless round-of-16 clash at Mercedes-Benz Stadium.
Enzo Fernandez headed home in the 92nd minute to complete one of the tournament's most dramatic comebacks before 68,239 spectators, sending the defending champions into the quarter-finals.
Argentina will face either Switzerland or Colombia in the last eight.
The result preserves Argentina's bid to become the first nation since Brazil in 1962 to retain the World Cup title, though Lionel Scaloni's side produced a performance that will leave little room for comfort.
Egypt, who arrived in Atlanta unbeaten through the group stage and round of 32, came within minutes of reaching the quarter-finals for the first time in the country's history.
The seeds of Argentina's near-catastrophe were planted inside the opening 25 minutes.
Egypt broke the deadlock in the 15th minute when Marwan Attia's pinpoint corner delivery found Yasser Ibrahim, who timed his leap perfectly to power a header past Emiliano Martinez from the centre of the box.
Argentina responded almost immediately through the sport's most reliable mechanism, winning a penalty when Hassan brought down Nicolas Tagliafico in the area.
Messi stepped up, only for Mostafa Shobeir to dive to his right and make the save, keeping Egypt in front. The goalkeeper was not done.
He pushed away a Mac Allister header before stretching full length to deny Julian Alvarez's first-time strike before half-time, producing a first-half display that would define the contest.
Argentina entered the break having generated significantly more pressure, recording an expected goals figure of 1.51 to Egypt's 0.21 and creating three clear-cut chances, yet trailed.
It was only the second time since the 2022 edition that Argentina had been behind at half-time in a World Cup match, and they had avoided defeat only once in their previous 10 such situations in the competition.
The second half brought further misery for the champions. In the 58th minute, Mostafa Zico appeared to double Egypt's lead on the counter, but a VAR review overturned the goal after adjudicators identified an earlier foul by Attia on Lisandro Martinez in the build-up.
The reprieve proved short-lived. Nine minutes later, Haissem Hassan carved open the Argentina defence down the right flank before cutting the ball back for Zico, who fired into the centre of the goal to make it 2-0 with 23 minutes remaining.
Argentina had lost all 13 previous World Cup matches in which they had trailed by two or more goals. History, and the statistics, pointed firmly toward an Egyptian triumph.
Scaloni responded with a double substitution, introducing Lautaro Martinez and Nico Gonzalez, and the changes began to shift the contest's rhythm. Egypt, who had defended with discipline and menace throughout, started to retreat deeper as the clock wound down.
The comeback began in the 79th minute. Messi, after two wayward attempts, produced a precise cross that Cristian Romero met with a firm header to pull one back.
Four minutes later, Gonzalo Montiel, himself a substitute, played the ball into Messi's path on the edge of the area, and the Argentina captain struck cleanly first time. Shobeir got a hand to the effort, but could only deflect it into the roof of the net.
Two-all, with seven minutes of normal time remaining.
With the stadium roaring and Egypt visibly rocked, the decisive moment arrived in stoppage time.
Alvarez released Lautaro Martinez down the right with a long ball, and the Inter Milan striker took his time before delivering a cross to the back post.
Fernandez arrived to head firmly into the far corner, sending the Argentina bench onto the pitch in scenes of extraordinary relief.
Messi's equaliser made him the first player in World Cup history to score in six consecutive knockout-stage matches.
He has now netted in all of Argentina's matches at the 2026 edition, continuing to rewrite the sport's record books deep into his international career.
Argentina recorded 19 shots to Egypt's five and generated an expected goals total of 2.8 to 0.98, but the scoreline remained in Egyptian hands for the vast majority of 90 minutes.
Egypt, who had lost five of seven World Cup matches prior to 2026, finished the tournament unbeaten against teams they did not progress past, and came within a Fernandez header of becoming only the fifth African nation to reach the last eight, after Cameroon, Senegal, Ghana, and Morocco.