A bizarre goal from Diego Costa - his third of this year's FIFA World Cup - was enough for Spain to earn their first victory in Group B on Wednesday, putting them level on points with joint leaders Portugal. The result was undeniably a fair reflection of the match - although the manner of the defeat was harsh on Iran, who frustrated their opponents for long periods and came desperately close to scoring on a number of occasions.
Although the Iranians were clearly the underdogs at the Kazan Arena, they started the match two points ahead of Spain in Group B - they defeated Morocco 1-0 in their opening match, while Spain could only draw their opener 3-3 against Portugal. Moreover, Carlos Queiroz's side conceded just two goals and were unbeaten in their qualifying campaign, so it seemed unlikely that they'd be pushovers - even for a side of Spain's calibre.
Roared on by their infectiously enthusiastic and loud supporters, Iran made a positive start, breaking with intent and winning a free kick in a dangerous position on the left, although it ultimately came to nothing. As expected, Spain soon started dominating possession, but failed to carve out any clear chances in the opening exchanges.
It was obvious that Iran's primary objective was to frustrate the Spanish, and they did so very effectively. Admittedly, they did also concede quite a few free kicks, but their more illustrious opponents were unable to capitalise on any of these opportunities.
In fact, Spain didn't really look like scoring at all, at least until David Silva volleyed over the bar from close range in the 30th minute. This was after Andres Iniesta and Isco had tried to inject a little spark into what had become a somewhat laboured display by La Roja.
Although the first half bore a striking resemblance to an 'attack versus defence' training session, Iran still threatened sporadically. Sergio Ramos had to head a dangerous cross behind for a corner, although it was subsequently defended easily enough. Silva had a shot blocked from close range and another one deflected behind towards the end of the first half, but that was about as good as it got for the 2010 World Cup winners in the first 45 minutes.
Despite Spain's overwhelming superiority in terms of technique and movement, they had singularly failed to test the Iran goalkeeper Alireza Beiranvand. Incredibly, they mustered just one shot on target in the first half - despite enjoying more than 80 percent of possession.
Fernando Hierro's side showed greater urgency at the start of the second half, and a Gerard Pique header was cleared off the line. Then Beiranvand was finally tested by a fierce Sergio Busquets drive, which the Iranian did well to save, if a little theatrically.
The underdogs were evidently struggling with Spain's more dynamic approach, and it seemed only a matter of time before a goal arrived. Remarkably, it was the Iranians who nearly broke the deadlock, when Karim Ansarifard fired into the side netting after some seriously unconvincing Spanish defending.
Finally, in the 54th minute, Spain scored the goal which reflected their superiority, though the goal itself was fortuitous at best. Iniesta found Diego Costa in the box, and Costa's shot hit Ramin Rezaeian, before rebounding back off the Atletico Madrid striker and into the net.
Now that they'd been forced to come out of their defensive shell, Iran showed far greater attacking intent, as Mehdi Taremi headed a decent opportunity wide. Then, unbelievably, it looked as though the Iranians had levelled the match - only for the goal to be correctly ruled out by VAR for offside.
Spain generally looked comfortable - though far from devastating - from that point on. Nevertheless, Iran still looked menacing at times, and Taremi failed to convert two excellent opportunities in the final quarter of an hour. First, he failed to connect with one superb cross, and then he headed another one over the bar, after Vahid Amiri had brilliantly nutmegged Gerard Pique.
Nevertheless, Spain held on for the victory, and will face Morocco on Monday evening in their final Group B match. At the same time, Iran will take on Portugal, knowing that a win over Cristiano Ronaldo's side will be enough for them to reach the round of 16.