Having already won the group, the Spanish began with a much-changed line-up but still made a strong start, Cristian Torres putting them ahead just a few minutes in. Iran turned the game on its head in a matter of minutes, though, when long-range shots from Moslem Mesigar, keeper Hamed Ghorbanpour and Ali Aligoli gave them a 3-1 lead.
Their pride wounded, La Furia Roja regained control at the start of the second period, pulling level with a Miguel Beiro cross-shot and a Javier Torres free kick. With nothing at stake, the action flowed from end to end before Mohammad Ahmadzadeh finished off a sweet team move to make it 4-3.
Ten minutes later Spain equalised again, this time through Javier Torres. Their relief lasted all of 30 seconds, however, Ghorbanpour emerging from his area to hammer home another long-distance free kick, his third goal of the tournament, and give his side a well-earned win.