Marcus Rojo's stunning finish four minutes from time kept Lionel Messi and Argentina's World Cup hopes alive to see off Nigeria 2-1 on Tuesday and set up a last 16 meeting with France.
Messi's first goal of the tournament got the two-time winners off to a perfect start in Saint Petersburg, but Victor Moses's 51st minute penalty had Jorge Sampaoli's men headed for a humiliating group stage exit until Rojo's late intervention.
The Manchester United defender, who had escaped conceding a second Nigerian penalty moments earlier after a controversial VAR review, thundered home Gabriel Mercado's cross to send the under-fire Sampaoli running down the sidelines amid wild scenes of celebration.
Messi missed a penalty in a 1-1 draw with Iceland and was largely bypassed in a 3-0 thrashing by Croatia that saw calls for Sampaoli to be sacked before their final group game.
However, Argentina avoided the abyss by the skin of their teeth to fight another day against the highly-fancied French in Kazan on Saturday.
Sampaoli made five changes from the Croatia game, with veterans of the Albiceleste's run to the final four years ago Gonzalo Higuain and Angel di Maria returning, but it was the recall of Ever Banega in midfield that provided the launchpad for Messi.
The Sevilla playmaker was restored to bring some order to an Argentine midfield overrun by Croatia's Ivan Rakitic and Luka Modric and proved his worth inside 15 minutes.
Banega's brilliant pass over the top of the Nigerian defence picked out Messi's run perfectly and, after cushioning the ball on his thigh, the five-time world player of the year erased the frustrations of his World Cup so far with an arrowed right-foot finish into the far corner.
Modric claimed Croatia "cut off Messi" in Nizhny Novgorod five nights ago, but he was back to close to his Barcelona best at the heart of all Argentina's best moves in a positive first 45 minutes.
Higuain just couldn't flick the ball beyond the onrushing Francis Uzoho from a defence splitting pass before Uzoho then tipped a Messi free-kick onto the post.
Argentina escaped just before the break when no penalty was given for Rojo's high challenge on Kelechi Iheanacho.
Nigeria felt that injustice was rectified just five minutes after the break, though, when this time Turkish referee Cuneyt Cakir did point to the spot when Javier Mascherano tangled with Oghenekaro Etebo at a corner.
Moses confidently stepped up to send Franco Armani the wrong way on his international debut and Argentina back to square one.
Messi produced a magical performance in Argentina's final qualifier with a hat-trick in Ecuador just to get his country to Russia.
But he couldn't recreate those heroics as Nigerian defenders swarmed around him everytime he was hopefully shovelled the ball by Argentine team-mates.
There was further VAR controversy when Nigeria were denied a second penalty when Rojo headed onto his own arm before substitute Odion Ighalo fired wide.
Ighalo missed another glorious chance when he shot too close to Armani and Nigeria were made to pay for their profligacy from the most unlikely source.
Sergio Aguero had been thrown on from the bench to join Messi and Higuain in attack, but it was Rojo who produced a striker's finish on his weaker right foot to spark delirious scenes of celebration among the tens of thousands of Argentines in the stands.
Chief among them was legendary 1986 World Cup winning captain Diego Maradona who reacted by raising the middle finger of both hands in just his latest controversial moment as a spectator in Russia.
Relief: Lionel Messi scored his first goal of the 2018 World Cup to give Argentina the lead against Nigeria