Amid the din, the final whistle barely heard, Iran’s footballers collapsed to the floor exhausted and someone decided to put “Y Viva España!” on the PA system. Spain had lived but dangerously. Iran had been defeated but only just.

Fernando Hierro’s team won 1-0, the breakthrough coming from a fluke that flew off Diego Costa’s knee. And if at that stage, when only they had really sought a goal, it would have been tempting to conclude that fortune favoured the brave, by the end this felt rather different. Spain led but then suffered – more than they had imagined. Iran resisted but then rebelled.

World Cup 2018: Iran 0-1 Spain – live! Read more

While the 2010 world champions scored once, Carlos Queiroz’s team might have scored three and twice thought they had scored one: the first hit the side netting, delighted subs and staff running from the bench before they realised; the second was ruled out for offside but, cruelly, not before celebrations were well under way; and with Iran switched to attack mode andSpain struggling to regain control, the third flew over from six yards late on, Mehdi Taremi barely able to believe it. The moment had gone.

The fortune Iran enjoyed against Morocco deserted them here. It also forced them into a change of plan that almost worked, talent brought to the fore. As for Spain, they secured a victory that leaves them well placed to progress. Asked if the feeling was relief, Hierro said: “The feeling is we have three points we said would be hard to get.”

They got them thanks to a goal that came early in the second period after a first in which they had the ball, eventually racking up 580 more passes than Iran, but were unable to rack up a goal against a side they felt had used old tricks. Diego Costa said “they provoked us; they were on the grass all the time,” while Hierro talked about a match with “lots of stoppages”, pointedly adding “the Spanish national team is in favour of fair play”. Above all, though, Spain had played a side that defended deep – and very, very well.

Spain expected that. Iran had gone 22 matches without defeat, keeping a clean sheet in 18. “They will make it very difficult,” Hierro had warned. They did that all right. What surprised, perhaps, was that ultimately they did not do so only when they were defensive; they did so also when they went looking for a goal, without reward.

Facebook Twitter Pinterest Saied Ezatolahi celebrates scoring against Spain – but his goal was disallowed for offside. Photograph: Sergey Dolzhenko/EPA

Hierro had insisted repeatedly that he would change little but Iran’s expected approach encouraged alterations. Koke, whose defensive cover they did not expect to need, was removed, leaving Andrés Iniesta and David Silva alongside Sergio Busquets. That allowed creativity, swifter circulation and the inclusion of Lucas Vázquez, offering width and a willingness to run – in theory.

At first it appeared that Iran would look to step out but they soon settled into what was often in effect a 6-3-1, the first two lines close. The game squeezed into a 20-metre strip running the width of the pitch near Iran’s area. Inside it Spain passed side to side, occasionally accelerating, usually led by Silva, but found breaking the lines a tough task. Lucas had been brought in for this but the space he is adept at running into did not exist. Diego Costa, too, was struggling.

Dani Carvajal sliced over; Silva’s shot hit Majid Hosseini; Sergio Ramos’s free-kick went into the wall and Silva sent another effort into the goalkeeper’s hands but there were few clear sights of goal. Iran stood firm, vulnerable only when caught coming out. With every clearance there was a roar mixed with the constant hum of air horns. This was an Iranian crowd – a female one too – that suffered when Silva hooked over and his deflected shot looped wide.

That crowd erupted early in the second half, subs and staff leaping from Iran’s bench, thinking they had scored. But Karim Ansarifard’s shot, superbly struck from a long throw, had actually flown into the side netting. And then, barely a minute later, people were racing off the Spain bench instead, relieved. Iniesta found Costa and, as he turned, Rezaeian sprinted towards him to clear, thumping the ball off his knee and in.

‘Ros! Si! Ya!’ Energised Russia is one nation under a World Cup chant Read more

That, one suspected, was that. But Iran stepped forward and soon there were people running from the Iranian bench again. This time it was all of them and they made it down to the corner, celebrating an equaliser after Ezatolhai shot past David De Gea. As they celebrated, though, the referee stood. To his right, the linesman’s flag was up. Players circled but he sent them away, trying to hear the message in his ear. It took a while, pause pressed on everyone’s emotions, until Andrés Cunha disallowed the goal. Afterwards Queiroz said a member of staff had been taken to hospital following the celebration. “We hope he’s OK,” he said.

It was still not over. The pace quickened and the pitch tilted a little more towards De Gea. A wonderful delivery swung across the six-yard box and then, at the end, the moment arrived. Amiri brilliantly slipped the ball through Piqué’s legs and swung in a superb cross. Steaming in, Taremi headed over from six yards.

“We left having lost 1-0 but we won respect; the players should be proud,” Queiroz said.