Spain edged out Iran in an absorbing contest to ensure they will reach the World Cup knockout stage with a draw in their final group game.
The 2010 champions needed a fortuitous Diego Costa goal after half-time, having been frustrated in an opening period in which they had 81% of possession.
Iran, who defended admirably until the ball ricocheted in off Costa, instantly showed more intent and thought they had levelled, only for Saeid Ezatolahi’s strike to be ruled out for offside.
Carlos Queiroz’s Iran side had gone close through Karim Ansarifard and Mehdi Taremi before the crucial offside call and their endeavour throughout seemed to endear them to the crowd at the Kazan Arena.
They survived a chaotic goalmouth scramble where Gerard Pique somehow failed to turn home from a yard out, but again showed heart and threatened late on, with Taremi heading over when well placed.
Fernando Hierro, installed as Spain manager two days before the World Cup started, knows his side will reach the knockout stage if they draw with Morocco on Monday.
Spain may feel they have faced several noteworthy hurdles already throughout their stay in Russia.
The sacking of coach Julen Lopetegui before the tournament was followed by a last-minute equaliser by Portugal in their opening game. Then came this significant examination.
Spain are accustomed to dominating possession against sides content to soak up pressure, but Iran’s deep 4-5-1 set-up in the first half afforded them only one shot on target. Costa cut an isolated and frustrated figure, with 12 first-half touches.
Iran set a record of 1,121 minutes without conceding a goal in qualifying and only after the break did Spain begin to find holes in a well-drilled defensive block, with Sergio Busquets forcing a fine save and Pique unable to flick home in the six-yard box.
Hierro’s side were typically neat with the ball – completing 90% of their passes – and their early second-half momentum told, with a Ramin Rezaeian clearance hitting Costa and finding the corner of the net. It was Costa’s ninth goal in his past nine international starts.
The fact he continued to hassle Iran’s defenders on a night when he was so often crowded out of the game is to his credit and, after scoring twice against Portugal, he looks to have made the lone striker role his own.
Spain top Group B courtesy of having collected fewer disciplinary points than Portugal.