BELO HORIZONTE, Brazil — The way Iran was defending, it was always going to take a little magic from Lionel Messi to send Argentina into the second round of the World Cup.
Until stoppage time Saturday, Messi had been stifled by Iran’s solid back line. Then, out of nowhere, the Argentina captain produced something very special, as he has done so many times for Barcelona, by scoring a stunning goal for a 1-0 victory.
Goalkeeper Sergio Romero, who watched the goal from the other end of the pitch, said Messi ‘‘rubbed his magic lamp and we won.’’
Messi was more pragmatic.
‘‘When I saw that I had scored I was very happy, because we were in added time already and wanted to qualify for the next phase,’’ he said.
Argentina coach Alejandro Sabella watched as Iran tightly marked his star player, but said he always had faith that Messi might deliver when it counted.
‘‘Messi continued on throughout the match,’’ Sabella said. ‘‘He had perseverance, patience, attitude. He always had an eye for goal in his own way.’’
It was Messi’s third World Cup goal since 2006. The match was also significant for him because it was his 88th Argentina appearance, surpassing Diego Maradona’s 87.
However, the Group F match had nearly been a disaster for Argentina. Besides defending, Iran also took the match to Argentina in the second half, creating several chances to win it and cause a tournament sensation.
Iran was punished, however, for those missed chances. Messi, getting a rare touch, quickly moved the ball toward his dangerous left foot and fired a curling shot from 20 yards just beyond the reach of the diving goalkeeper and into the left corner of the net.
The goal showed why Messi has been voted world player of the year four times.
Up until that point, he had been kept quiet by Iran’s stoic defending, while Argentina had at times been exposed to counterattacks.
‘‘It was a difficult game to be honest,’’ Messi said. ‘‘They were able to close up at the back, so it was difficult for us to break down the defense. It was very hot for us.’’
Iran had several chances to win it, especially in the second half. The best of those opportunities came in the 67th minute, when midfielder Ashkan Dejagah’s powerful header from close range was tipped just over the bar by Romero.
‘‘We know that it would be a difficult, tense match,’’ Romero said. ‘‘Thank God I could get my hand on the ball and it didn’t go in.’’
Earlier, lone striker Reza Ghoochannejhad’s header from close range was saved by Romero after a cross from the right. He also missed a chance for a late winner when his shot was again saved by Romero.
Iran coach Carlos Queiroz said two people made the difference: Messi and referee Milorad Mazic. Queiroz said the referee should have pointed to the penalty spot when Argentina right back Pablo Zabaleta mistimed his challenge on Dejagah in the second half.
‘‘I hope they don’t punish me, but I'm telling the truth: It was a penalty,’’ Queiroz said, stressing that Mazic had a clear view. ‘‘The referee played a role in this game.
‘‘Messi was great, he scored the winning goal. The referee, I'm sorry to say, was not.’’
Before the match, Iran faced criticism for its defensive tactics after a dour 0-0 draw against Nigeria. But before Messi’s strike, Iranian and Brazilian fans were singing ‘‘Ole, ole, ole, ole, Iran Iran!’’ in recognition of the team’s attempts to score a winner.