LIONEL Messi scored twice, including a sumptuous free-kick, to help Argentina beat Nigeria 3-2 and ensure qualification to the knockout stages as winners of Group F.
Messi's two goals were twice cancelled out by Nigeria's Ahmed Musa but Marcos Rojo's second-half finish made sure Argentina took all three points.
Despite their defeat, Nigeria also progressed to the last 16 as Iran were beaten 3-1 by Bosnia-Herzegovina - meaning the Super Eagles go through as runners-up.
Argentina will now face the runners-up of Group E, with either Switzerland or Ecuador their most likely opponents, while Nigeria will almost certainly play France.
Messi's double means he is now joint top-scorer with Neymar on four goals and while the number 10 was substituted and spared the final half an hour of the game, his emphatic form means Argentina will go into the competition's latter stages in high spirits.
It took less than three minutes for the South Americans to break the deadlock.
Javier Mascherano fired an incisive pass to Angel Di Maria and while the winger's shot was saved by Vincent Enyeama, the ball cannoned back off the near post and into the path of Messi - who shot high into the net.
One minute and 20 seconds later, however, Nigeria were level. Michel Babatunde broke from midfield and played the ball left to Musa who skipped inside Pablo Zabaleta before curling the ball brilliantly past Romero and into the far corner.
Argentina almost restored their advantage soon after when Messi slid in Gonzalo Higuain but the Napoli striker could only find the side-netting from an acute angle after dribbling round the goalkeeper.
After a pulsating opening 10 minutes, the game tightened up with Nigeria successfully able to stifle Argentina's attacking talents.
Di Maria skewed a shot wide from the edge of the area just before the half-hour mark and Peter Odemwingie fired a long-range shot over the bar as both sides struggled to create clear-cut chances.
Sergio Aguero's injury-plagued season continued as the Manchester City forward hobbled off in the 37th minute and was replaced by Ezequiel Lavezzi.
Two minutes before the break, Messi fired a bending free-kick from 40 yards towards the top corner but Vincent Enyeama was able to dive across and push the ball past the post.
Moments later the Argentina number 10 was given a second opportunity, slightly closer in, and this time he made no mistake, chipping the ball over the wall and beyond Enyeama to make it 2-1 on the stroke of half-time.
The second period began just as frantically as the first - with two more goals in the opening five minutes.
Nigeria drew level for the second time in the match and again it was Musa with the strike, as he ghosted through the Argentina defence before slotting past Sergio Romero to make it 2-2.
The Super Eagles' parity was short-lived, however, as the lively Di Maria unleashed a fizzing shot from the edge of the area which Enyeama did well to palm behind.
From the resulting corner Argentina found the net as Nigeria's defence failed to clear and Rojo was left free to turn the ball home from close range.
Messi was denied the chance to complete his hat-trick with Alejandro Sabella opting to rest his talisman and bring on Ricardo Alvarez shortly after the hour.
Argentina almost extended their lead in the 78th minute when Di Maria's dinked free-kick allowed Lavezzi to volley from close range but his shot was blocked by the feet of Enyeama.
Nigeria then went close at the other end as Musa again cut inside Zabaleta on to his right foot but this time the Argentina full-back read the move and was able to block the shot.
Ezequiel Garay should have put the result beyond doubt with a header at the back post in the final 10 minutes but it proved inconsequential as both teams booked their spots in the knockout stages.