Time was melting away for Argentina on Tuesday — on the game with Nigeria, on the four-year campaign and on Lionel Messi's efforts to win his first World Cup title in probably his final attempt.

And then Marcos Rojo smoked Gabriel Mercado's cross into the lower right corner of the net, triggering bedlam in a pro-Argentine venue. Rojo's wicked volley in the 86th minute allowed Argentina to escape early elimination from the World Cup by beating Nigeria 2-1 in St. Petersburg, Russia.

Messi had scored his first goal of the tournament, but after a Nigerian equalizer early in the second half, his side needed another goal to claim one of the top two spots in Group D. Without that late goal, Messi, 31, might have retired from international soccer for a second time — and for good this time.

Instead, and combined with Iceland's 2-1 defeat to first-place Croatia, Argentina (four points) jumped over the Nigerians (three) and Icelanders (one) to earn a game with France on Saturday.

"I knew that God is with us," Messi said, "and he wouldn't let us get eliminated."

Messi's first-half goal was an exquisite strike, the 65th goal of his international career. From a long pass over the defense by Ever Banega, Messi caressed the ball with his left thigh, took another touch with his left foot, and then delivered a smooth right-footed finish into the corner.

"This is Messi," Nigeria coach Gernot Rohr said with a shrug.

Nigeria tied it with a penalty kick converted by Victor Moses following a 49th-minute corner. The African nation was only a few minutes away from qualifying for the knockout stage for the fourth time.

Nigeria was unhappy about not being rewarded a penalty kick on a handball with about 15 minutes remaining. Rojo was the only Argentina defender in the penalty box, and he mistimed a header and the ball ended up glancing off his left arm.

Referee Cuneyt Cakir used video to review this one and stood by his initial decision not to award a spot kick.

"I don't understand how that was not a penalty," captain John Obi Mikel said. "It was a clear handball. If you look at this game yesterday against Portugal, this was even worse."

Croatia 2, Iceland 1: Ivan Perisic capitalized on a defensive error to score a 90th-minute winner in Rostov-on-Don, giving Croatia a victory over Iceland and first place in Group D.

The Croats won all three of its group-stage games and will face Denmark on Sunday. Iceland could have finished second in the group with a victory.

Fielding a side filled with reserves after already being assured of a spot in the round of 16, Croatia started to take control of the match in the second half.

Milan Badelj, moments after hitting the bar, scored the opening goal in the 53rd minute. He sprinted into the area and sent a bouncing shot past goalkeeper Hannes Halldorsson.

Iceland tied the score in the 76th minute when Gylfi Sigurdsson scored on a penalty kick.

"I'm upset with the conceded goal, but ... we won nine points, the goal difference is 7-1, and we have top spot in the group," Croatia coach Zlatko Dalic said. That is fantastic."

Group C

France 0, Denmark 0: A game no team needed to win became the game no fan would want to watch. France and Denmark produced the World Cup's first scoreless draw at the 37th attempt amid boos and whistles from fans in Moscow.

The slow-paced game was out of step with a vibrant tournament. But it advanced both teams to the round of 16 unbeaten, with the bonus of no players suspended and no serious injuries.

The draw would always have ensured that outcome, and became inevitable in the second half as Peru beat Australia 2-0 at the same time.

"We did what we needed," Denmark coach Age Hareide said, praising his team for a disciplined display. "We would have been stupid to open a lot of space for the French team."

Peru 2, Australia 0: The Peruvians gave their fans a reason to celebrate when they ended Australia's hopes of advancing.

The Australians had to beat Peru and hope Denmark lost to France in the other Group C match, but neither result occurred.

Andre Carrillo's 18th-minute goal — a half-volley from inside the area — was Peru's first in a World Cup since its last appearance 36 years ago. Peru hadn't won in the World Cup match defeating Iran in 1978.

Australia striker Tim Cahill, a 38-year-old veteran who entered the match in the 53rd minute, had a chance to become only the fifth player to score in four World Cups, joining Pele, Uwe Seeler, Miroslav Klose and Cristiano Ronaldo. But he had few chances.

Note

• Videos posted on social media showed Argentina great Diego Maradona needing help to leave the stands. There was no immediate information on his health, but about two hours later, a photograph of Maradona smiling at the airport was posted online.