Iran's 3-1 loss to Bosnia-Herzegovina in the group's other fixture was enough to see the Super Eagles make the second round of the tournament.
However, Nigeria got themselves level just one minute later when Ahmed Musa cut in from the left before curling the ball into the far corner.
The Argentines responded by creating two decent chances in quick succession, but Gonzalo Higuain fired wide on the angle after Di Maria's drive had been saved by the goalkeeper.
© Getty Images
Di Maria continued to be Argentina's most dangerous threat during the first half, as demonstrated by two further efforts that had Nigeria worried.
A strong opening 45 minutes for the South Americans was soured towards the end when Sergio Aguero was taken off with a possible leg strain, but they were able to go back in front in the first minute of stoppage time as Messi curled a free kick into the top corner.
Nigeria enjoyed a strong start to the second period, and they were rewarded on 48 minutes thanks to Musa's calm finish past Sergio Romero after being played through on goal.
© Getty Images
As the Africans celebrated their equaliser, Argentina got their noses in front once again just three minutes later as Marcos Rojo bundled the ball home from a corner.
Nigeria came close to an equaliser on 73 minutes when Musa volleyed over the crossbar before substitute Ezequiel Lavezzi was denied at the other end.
The Super Eagles pushed hard for an equaliser late on, but it mattered little as Iran's defeat to Bosnia-Herzegovina was enough to see them through.