Lionel Messi scored twice to help Argentina beat Nigeria 3-2 as both sides progressed from 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 and finished top of the table.
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.
Messi's double means he is now the 2014 World Cup's joint top scorer with Neymar on four goals and, while the No. 10 was substituted and spared the final half-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 that 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.