The Albiceleste, with just one point to their name, headed into a final Group D fixture knowing that only a win would be enough to keep their dreams of global glory alive.
Messi got them off to the perfect start, with a sublime finish inside 14 minutes seeing the Barcelona talisman record the 100th goal at a Russian showpiece.
Victor Moses restored parity from the penalty spot for Nigeria, but Marcos Rojo was to have the last word four minutes from time, with an unlikely hero securing progress in dramatic fashion.
Messi told TyC Sports after a thrilling encounter in St Petersburg: “We were confident that we would win this game.
“It's wonderful to have won it this way. It is a well-deserved joy.
“I knew that God is with us and he was not going to leave us out. I thank all the people who are here, for all their sacrifice, and all those who are in Argentina who were always with us. The shirt of the national team is above all.”
Manchester United defender Rojo found himself in the right place at the right time as Argentina sought inspiration with time running out.
His controlled volley, with his weaker right foot, sparked scenes of wild celebration as Jorge Sampaoli’s side survived a huge scare.
There is still much work to be done by a side that was held by Iceland and beaten by Croatia, but Rojo acknowledges that anything is possible once knockout competition begins – particularly with Messi looking more like his old self.
“Lionel Messi had told the guys he was going to score a goal more than ever.
“The goal is for my family and for this group that deserves it. Let's go Argentina!”