Spain have made it through to the knockout round of the 2018 World Cup after drawing 2-2 with Morocco at the Kaliningrad Stadium in Russia on Monday night.
On an all-important night for Group B - except, of course, the Moroccans, who were simply playing for pride - Fernando Hierro's men knew they'd have to avoid defeat to ensure passage through to the next round.
The game got off to a very fiery start, with some heavy challenges going in on both ends in the opening minutes. Gerard Pique was quite lucky to remain on the pitch after putting a two-footed challenge in on striker Khalid Boutaib in only the eighth minute.
The Spanish defender didn't even see yellow and VAR wasn't consulted, perhaps due to the fact that very little contact was made.
Boutaib, though, got his revenge on the Spanish goal, taking advantage of a shocking turnover from La Roja in their own half to break through on goal and slot home on minute 14, giving the Atlas Lions their first goal of the tournament.
The 2010 winners wasted little time coming up with a response, however, as some impressive movement above the Morocco area left Andres Iniesta to break onto a pass in the box and then cut back for Isco, who blasted into the top of the net from close range in the 19th minute.
Morocco nearly got a second in the 25th minute and needed to be bailed out by David de Gea after Pique and Sergio Ramos both fell asleep on a long throw-in to let Boutaib in on goal again. The forward's shot from the six-yard box was snuffed out by De Gea, but only because his last touch was a bit too heavy.
Another cut back from Iniesta gave Diego Costa a huge chance to pull Spain ahead with the last kick of the half, but the Atletico Madrid man could not make proper contact with the ball as he slid in an attempt to stab it in from a few yards away.
The striker could only watch as his attempt flashed wide of the far post and that would be it for the period as the whistle beckoned the players into the tunnel tied at one goal apiece.
Spain, though, had done enough up until that point to qualify, despite Portugal going ahead of Iran in their own match at the Mordovia Arena on the stroke of half time.
The North Africans appeared the hungrier of the sides in the second half and an aerial ball from deep in the 49th minute well-nigh set Moubarak Boussoufa up with a goal. De Gea, though, came out to punch clear.
Morocco almost made Spain pay again just six minutes later, with Nordin Amrabat hitting a rocket from distance, smashing his foot across the ball from the right side to rattle the woodwork and nearly bounce past the goal line.
La Roja got a chance of their own a few moments later. Isco, who took his side level in the first half, got his head to a cross and looped a header goalward, beating the Moroccan keeper. Romain Saiss, however, was alert enough to clear it brilliantly off the line with his head.
The Atlas Lions would go on to shock the Spaniards again, scoring off a corner that resulted from Pique blocking a shot on goal. Youssef En-Nesyri, who had come on in the second half as a substitute, rose over both Pique and Ramos to powerfully head past De Gea on minute 81, prompting a deafening roar as the Morocco fans erupted in effusive celebration.
The Spaniards were handed four minutes of stoppage time to salvage something from the match. And substitute Iago Aspas did so a few seconds past the 90, expertly driving one home with a flashy back-heel coming off a quickly-taken short corner that was immediately played into the box.
The goal was initially ruled offside, but a VAR check had the decision reversed, with replays showing that the striker was indeed onside.
There would not be enough time for another one from Morocco. And a late leveller from Iran against Portugal meant that the Spaniards had even topped their group on goal difference.
They will now look ahead to their match against hosts Russia in the round of 16, having done just enough to emerge Group B winners.