Lione Messi scored an injury-time winner to deny Iran a point as Argentina won 1-0 to make it six points from two matches in Group F and book their place in the round of 16.
The Argentines, who won their first match 2-1 against Bosnia-Herzegovina, had been tipped to win comfortably against Iran on Saturday, but Messi and his teammates were frustrated by their opponents and on a different day might have even endured a shock loss.
Argentina dominated possession during the first half but struggled to create clear goalscoring opportunities. After Sergio Aguero and Gonzalo Higuain both saw shots saved by Alireza Haghighi, Ezequiel Garay spurned a great chance as he headed over.
Up the other end, Iran came close to stunning their opponents just before half-time when Jalal Hosseini met a corner inside the six-yard box only to see his header flash off target.
Argentina goalkeeper Sergio Romero was called into action early in the second half as Reza Ghoochannejhad headed goalwards from Pejman Montazeri's cross, only to see the effort palmed away.
Ashkan Dejagah then had a penalty claim turned down by referee Milorad Mazic, after Pablo Zabaleta slid in for the ball in the box, before the winger forced Romero into a fine save, as the tipped a header over the bar.
Ghoochannejhad had one last chance to claim a memorable win after he broke clear in the final moments only to see his effort saved by Romero.
But, in the first minute of injury-time, Messi worked his magic. The Barcelona forward curled home beautifully with his left foot from outside of the box to clinch a dramatic victory.