The Super Eagles were heading through to the last 16 at Argentina's expense with four minutes to go of the final Group D game, but Rojo's sensational low volley saved Jorge Sampaoli's men and set up a showdown with France in the next round.
Messi gave Argentina the lead in St Petersburg on Tuesday, the Barcelona superstar scoring a stunner to bring up the 100th goal of Russia 2018.
But when Javier Mascherano dragged down Leon Balogun in the box shortly after the restart, Victor Moses stepped up to roll Nigeria level and within touching distance of progressing.
Sampaoli sent on attackers Cristian Pavon, Maximiliano Meza and Sergio Aguero, but it was defender Rojo who came up with a quite brilliant winner.
The right-wing cross from another defender, Gabriel Mercado, was perfectly placed for Rojo to arrive late and slam home an improbable, unstoppable finish that extends Argentina's stay at the World Cup.
Players to score Goal 100 of a #WorldCup
Not a bad collection of players pic.twitter.com/4cqSvG6pui
— FIFA World Cup (@FIFAWorldCup) June 26, 2018
After scoring a brace in Nigeria's win over Iceland, Ahmed Musa sought to test debutant goalkeeper Franco Armani early, but narrowly cleared the crossbar with his ambitious effort.
Argentina made a nervy start before taking the lead in the 14th minute thanks to some Messi magic.
Ever Banega was making his first World Cup start and the Sevilla star's ball over the top was perfect, Messi controlling the ball on his thigh and left boot in one fluid movement before lashing an unstoppable right-footed drive past Francis Uzoho.
The Nigeria goalkeeper was rapidly off his line to deny Gonzalo Higuain as Argentina sought a second and the teenager was brilliant again as Messi took aim in the 34th minute.
Leon Balogun brought Angel Di Maria down 25 yards from goal, but, while Messi beat the wall with his free-kick, Uzoho got the slightest of touches to tip the shot on to his left-hand post.
Oghenekaro Etebo narrowly missed with a long-range free-kick before Rojo came up with one of the most dramatic moments of modern World Cup history in the 86th minute.
2 - Marcos Rojo has scored both of his World Cup goals against Nigeria. Bogeyman. pic.twitter.com/XwwJwEwuAg
— OptaJohan (@OptaJohan) June 26, 2018
Mercado raided down the right and bent a delicious cross into the penalty area, Rojo timing his run perfectly to tuck home a low right-footed volley that gave Uzoho no chance.
Argentina's reward will be a last-16 clash against Group C winners France, with Nigeria - the youngest squad at the World Cup - left heartbroken by Rojo's stunning strike.
Photo Getty Images. Caption: Argentina celebrate Marcos Rojo's goal