Argentina rescued their World Cup hopes in dramatic fashion on Tuesday as defender Marcos Rojo scored a stunning volley to snatch a late 2-1 win over Nigeria and set up a last-16 match against France.
Lionel Messi set the two-time winners on their way with his first goal in Russia but Victor Moses equalised from the penalty spot and as time ticked away the increasingly ragged South Americans appeared to be heading home.
But Rojo made a surprise appearance in the box to turn home a cross from Gabriel Mercado from the right with a crisp side-footed volley in the 86th minute to send the Argentine fans in Saint Petersburg -- including the watching Diego Maradona -- into raptures.
The Manchester United defender had escaped conceding a second penalty for Nigeria minutes earlier after a controversial VAR review.
"It is marvellous to have won it in this manner. It is a deserved joy," Messi said in quotes on Argentina's official Twitter account.
"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."
Argentina was held by Iceland in their tournament opener and then humiliated 3-0 by Croatia, putting the 2014 finalists on the brink of a first-round exit.
Their struggles came after their pre-tournament preparations were wrecked by controversy and poor form, coupled with a reliance on a top-heavy, limited squad.
The Argentine federation was even forced to confirm that Jorge Sampaoli would continue for the final group game amid rumours of a rift between players and coach.
At the drama played out in Saint Petersburg, 1,500 kilometres (950 miles) away in Rostov-on-Don, Croatia snuffed out the challenge of Iceland, scoring late through Ivan Perisic to seal a 2-1 win and complete a perfect group stage.
Croatia will face Denmark in the first knockout round in Nizhny Novgorod on Sunday but Nigeria and Euro 2016 surprise package Iceland will head home.
Croatia took the lead thanks to a slick second-half volley by Milan Badelj. Gylfi Sigurdsson equalised from the penalty spot before Perisic struck late.
Croatia were already through to the last 16 and coach Zlatko Dalic rested most of the side that thumped Argentina 3-0, with only captain Luka Modric and the winger Perisic keeping their places.
"Our goal is achieved," said man-of-the-match Badelj. "We are top of the group and we are ready to compete in the second round of the World Cup.
"Now we can concentrate on preparations for the knockout stage. This is a big new win for Croatia. There is no special celebration, let's go further, step by step through the tournament."
France top group
Earlier, France and Denmark produced the first goalless match of the tournament in front of 78,000 spectators at the Luzhniki Stadium in Moscow.
Didier Deschamps rested goalkeeper Hugo Lloris and midfielder Paul Pogba among six changes and his side struggled to create any clear-cut chances against a determined Denmark.
Deschamps immediately switched his focus towards what he called the "second competition" after the uninspiring contest.
"There's a second competition that's going to start, the last 16 is straight elimination," said the coach, who must now prepare his players to face Messi and Argentina.
"There's a mountain in front of us now. But we're there and we're full of ambition to get to the next stage."
Australia will go back to the drawing board after they ended bottom of Group C with a solitary point following a 2-0 defeat to Peru, who are also heading home.
Andre Carrillo and Paolo Guerrero, the veteran who was only cleared to play days before the tournament after having a ban for taking cocaine lifted, scored in Sochi.
Tim Cahill, the 38-year-old Australian midfielder, came on as a substitute for his first appearance in his fourth World Cup but was unable to influence the outcome and the Socceroos will have to look to the future with talents such as 19-year-old Iranian-born Daniel Arzani.