Oh VAR, you old stick in the mud, you. For a few glorious seconds last night, a nation rejoiced as Iran – and the watching world – thought they had shocked Spain by snatching an unlikely equaliser to Diego Costa’s fortunate opener for Spain.

Alas, the fairytale was brought to an abrupt ending, justifiably as it turned out, as replays showed the referee what the naked eye had missed, namely that Saeid Ezatolahi had strayed offside before smashing the ball into the Spanish net. It may have been cruel in the nature that a moment of national celebration was snatched away, but what VAR lacks in romanticism, it has proven to more than make up for in cold, pragmatic accuracy. And justice.

In the end, it is Spain who march on, and while there was more than a touch of fortune about their eventual victory, it was hard to argue that they didn’t deserve it. They had north of 70 per cent possession but will have to remedy the shakiness at the back that cost them against Portugal - and so nearly did here - if they are to be world champions once more.

Memories of that triumph in South Africa were brought back in rather unwelcome fashion as the Iranian support soundtracked the evening with the drone of the vuvuzela, but it was a bearable addition to the atmosphere for one night only in the Kazan Arena.

The pattern of the game was set early and was much as expected, with Spain enjoying the majority of possession and the massed ranks of the Iranian defence – who kept 14 clean sheets in 18 qualifiers – happy enough to keep them at bay by any means necessary.

You had to wonder how long Carlos Quieroz’s men could endure playing the entire match as if they were holding on to a single-goal lead in the final minute. It was an intriguing tactical battle but did little for the spectacle.

An incisive passing move did present David Silva with a decent sighter just before the interval, but Morteza Pouraliganji threw himself in the way to block behind. Was it pretty to watch? No, but beauty is in the eye of the beholder, and there was much to be admired about the dogged and disciplined defending on display.

Spain were desperate for the early breakthrough at the start of the second half to open the game up, and they almost got it as Gerard Pique came close to connecting with a corner and then Sergio Busquets forced a decent save from the previously underworked Alireza Beiranvand in the Iran goal.

It felt as though a goal was imminent, but against all odds, it almost arrived at the other end. A long throw was partially cleared by Pique, and Karim Ansarifard blasted into the side-netting on the half-volley. The Iranian fans thought it was in, but they were soon brought back down to earth, and then some, as the ball flew in at the other end in bizarre fashion.

Diego Costa took the ball into his feet and turned in the area, and just as he was about to get a shot away, Majid Hosseini arrived to tackle. He only succeeded though in crashing the ball off of Costa’s knee and it went skidding into the net.

It was unlucky, but from a neutral perspective, it was what the game was crying out for. Straight away, Iran committed more bodies forward, and suddenly, we had an end-to-end game on our hands. And they were almost instantly rewarded.

A free-kick into the Spanish area caused chaos, and Ezatolahi latched onto the loose ball to smash home under David De Gea. The Iranians exploded with joy, led by the riotous celebrations of Ezatohali, but again their jubilation was short-lived. A raised arm from the referee Andres Cunha – who awarded the first ever penalty at a World Cup using VAR on Saturday – signalled a review, and the goal was correctly ruled out for offside. Harsh, but fair, and again VAR had proven its worth in this tournament.

Iran may have got their moment of glory after all, as a bit of magic on the left from Vahid Amiri saw him nutmeg Pique and cross to the back post. It was begging to be headed in, but Mehdi Taremi got his timing out by a fraction, sending the ball over and out.