Spain edged out a gallant 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.