Marcos Rojo's stunning finish four minutes from time kept the Albiceleste's World Cup hopes alive tonight, as Argentina saw off Nigeria 2-1 to set up a last 16 meeting with France.
Captain Lionel 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 heading for a humiliating group stage exit until Rojo's late strike.
The Manchester United defender, who had escaped conceding a second Nigerian penalty moments earlier after a VAR review, thundered home Gabriel Mercado's cross with a right-foot volley – on his weaker foot – 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 Higuaín and Ángel di María returning, but it was the less heralded 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 he 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.
Higuaín 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 River Plate's 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 debate when Nigeria were denied a second penalty when Rojo accidentally 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 Agüero had been thrown on from the bench to join Messi and Higuaín in attack, but it was Rojo – one of only three defenders on the pitch yet still in the opposition's box – 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.
The national team came here needing only to win as long as Croatia, top of Group D and already through, did as expected and held off Iceland. They held up their side of the bargain, winning 2-1 in Rostov and will face Denmark on Sunday.
Argentina have now earned a go at France in Kazan on Saturday. The Albiceleste live to fight another day.
A relieved Lionel Messi said Argentina deserved their place in the last 16.
"It is marvellous to have won it in this manner. It is a deserved joy," Messi said. "We knew God was with us and wasn't going to let us go out. I thank all the fans that are here, for all their sacrifice and to all those in Argentina that were always with us. The shirt of the national team is above all else."