Lionel Messi curled a stunning 91st-minute winner to send Argentina through to the World Cup knockout stage and rob the excellent Iran of a deserved point.
Iran spent much of the first half under pressure but more than once threatened to inflict what would have been a huge upset.
Argentina’s celebrations at the final whistle were wild and prolonged, while the sight of coach Alejandro Sabella embracing Messi at the tunnel gave an indication of what this meant to the two-time champions.
The build-up was dominated by talk of a rift between Messi and Sabella, the captain having expressed his displeasure at the 5-3-2 formation used in the first half againstBosnia-Hercegovina when Messi also scored the decisive goal.
Sabella duly reverted to the Barcelona forward’s preferred 4-3-3 and was rewarded by his star man at the last.
Iran looked devastated at the end but must take immense confidence from a performance that combined defensive resilience with attacking adventure – and from the knowledge they could still qualify.
Carlos Queiroz’s men actually created the first meaningful chance when Jala Hosseini headed wide from Ashkan Dejagah’s free-kick, although Argentina then assumed control.
Javier Mascherano and Fernando Gago provided a solid base for Angel Di Maria and full-backs Pablo Zabaleta and Marcos Rojo to support Messi, Gonzalo Higuain and Sergio Aguero.
Iran goalkeeper Alireza Haghighi displayed superb reflexes to foil Higuain and save one-handed from Aguero. Rojo then headed narrowly wide, Messi was off target with a free-kick and Ezequiel Garay nodded inches over the bar. The Iran fans celebrated every reprieve like a goal.
Argentina were meeting a wall of resistance every time they attacked but Iran’s impressive defending ought to have been no surprise – they kept more clean sheets in qualifying than any team at the tournament. And when not thwarting the South Americans’ forwards, Queiroz’s team again came close to a goal of their own with another Hosseini header.
Iran’s preparations for the competition had been hampered by political sanctions that affected their funding and ability to organise friendlies, but they looked fully prepared and again came close to taking a shock lead through Reza Ghoochannejhad.
Masoud Shojaei surged forward and fed Pejman Montazeri to cross for the Charlton Athletic striker, who would have scored had his header been aimed anywhere other than straight at Argentine keeper Sergio Romero.
But the chance served to further bolster Iran’s self-belief and after Dejagah had a strong penalty claim rejected by referee Milorad Mazic, the Fulham man was thwarted by Romero’s fingertips as he met another Montazeri cross with a powerful header.
Messi worked hard to swing the momentum back in Argentina’s favour, slotting wide after a quick break and sending a free-kick into the side-netting, while Sabella introduced Rodrigo Palacio and Ezequiel Lavezzi in place of Aguero and Higuain as his side pushed hard for a winner.
Still chances came for Iran, however, Ghoochannejhad nearly stealing the win, only for Romero to make a diving stop – and that miss proved costly when captain Messi stepped up with a wonderful finish into the far corner to send Argentina through with a game to spare and keep them on course for a first World Cup since 1986.