In what was a thrilling contest at the Kaliningrad Stadium, Spain twice came from a goal down to salvage a 2-2 draw with a gutsy Morocco side that had already been eliminated. The point gives La Roja five in total as they top Group B to set up a Round of 16 match against tournament hosts Russia Sunday in Moscow.

Iago Aspas’ delightful back-heel flick had first been disallowed as the Celta da Vigo defender was ajudged to have been offsides, but after consulting with video assistance technology, the decision was rightly overturned.

The Atlas Lions leave the World Cup with a memorable point after two fantastic performances in the previous group stage games. It’s no secret the two countries have been at odds over a couple of enclaves on Africa’s Mediterranean coast for years and the tension showed at the beginning of the match.

The Moroccans’ game plan was to be physical and five of their players were booked before barely half an hour was out. Spain were not without treading the danger line as Gerard Pique should have been sent off for his two-footed tackle on Khalid Boutaib.

He’d left the ground when he leapt into the tackle, though Younes Belhanda could have also seen red for his clumsy challenge on Andres Iniesta. Iniesta was then guilty of a heavy touch on a ball barely 15 minutes in and him and Sergio Ramos seemed to be confused over who should take control and rescue the situation.

Each left the task for the other, resulting in Boutaib gaining control of the ball, sprinting through 20 yards with it, and just about managing to tuck away through David de Gea’s legs to give the North Africans a 1-0 lead.

He almost made it two having latched onto nothing more than a throw-in over the top into space where Dani Carvajal should have occupied. De Gea stood firm and saved with his knee, sparing his defender’s blushes.

Spain looked both furstrated and disorganized, but the quality of this team cannot be questioned and within five minutes of Boutaib’s opener, they were level.

A fine sequence of passing quick exchanges between Iniesta, Isco and Diego Costa concluded with Isco tapping the ball past Morocco keeper Monir El Kajoui to square the contest at 1-1.

Isco then swung a delectable corner only to see Sergio Busquets head over El Kajoui’s goal, the 2010 world champions still struggling to gain control. The remainder of the first 45 minutes was played mostly on Spain’s terms, but they couldn’t capitalize with the goal that perhaps could have broken Morocco’s backs.

Isco’s header was cleared off the line by Ghanem Saiss, David Silva struck at El Kajoui from short range after another bit of brilliant passes, eight in total.

Costa had little to no influence on the game, turning one ball around the corner neatly for Thiago Alcantara, whose finish was speculative at best, El Kajoui in the goal was rarely threatened.

The Atlas Lions were unlucky not have not gone ahead just after halftime as they looked more potent than their more accomplished opponents, Noureddine Amrabat crashing against the bar.

Nine minutes from time, they took a deserved lead, substitute Youssef En-Nesyri stunned the Spanish, the Malaga man rising above Sergio Ramos, powering home a header past De Gea to give Morocco a 2-1 lead.

But there were to be two more twists. Isco’s cross flicked in by Aspas in the first minute of stoppage time. Played onside by Mbark Boussafa, the fourth official’s flag went up, signalling for offside before the decision was reversed, sending La Roja to the summit of Group B thanks to Iran’s Karim Ansirafard equalizing from the spot against Portugal, awarded after a VAR review.