The Atlas Lions opened their Group F campaign with a goalless draw against Croatia before picking up successive wins over Belgium and Canada to claim an unexpected first-placed finish.
Walid Regragui's men are now aiming to become the first Morocco team to progress to the last eight of football's biggest competition, and there are plenty of reasons for fans to be positive of an upset against the 2010 champions.
Here, Sports Mole takes a look at three reasons for Morocco to be confident of coming up trumps and dumping Spain out of the tournament.
Defensive excellence
No opposing player has managed to find the back of the net against Morocco at the 2022 World Cup, and the Atlas Lions have only conceded once in the entire tournament, which was an own goal by Nayef Aguerd.
The West Ham United man will not want to look back on that one fondly, but he has otherwise played his part in a formidable defensive unit for Morocco, whose backline of Aguerd, Romain Saiss, Achraf Hakimi and Noussair Mazraoui is not one to be messed with.
Number one goalkeeper Yassine Bounou has also made quite the impression with Sevilla, and it will not come as a shock to learn that Morocco were the joint-best defensive side in the group stage - a total of five other teams also shipped just one goal in their opening three matches.
Remarkably, Aguerd's own goal was the first that Morocco had shipped in 540 minutes of football, as they had previously recorded six successive shut-outs against Liberia, Chile, Paraguay, Georgia, Croatia and Belgium.
Keeping the latter two at bay is no mean feat, although Regragui's rearguard now face a true test of their mettle against a Spain side who scored nine goals in the group stage - the highest of any team alongside England.
Unbeaten record
Morocco's unbeaten record in all competitions now stands at an impressive six matches - during which they have won six and drawn a further two - and avoiding defeat at the World Cup has also been one of their specialities in recent memory.
While plenty of the big teams succumbed to unexpected defeats in the group stage, Morocco were one of five teams to go through the opening phase unbeaten, and the Atlas Lions have now avoided losing in four World Cup matches since being held to a 2-2 draw by their upcoming opponents in 2018.
Even then, Morocco were on the verge of victory before Iago Aspas scored an injury-time equalizer for Spain in their final group contest, but Regragui's side could now equal an African record that has stood for 32 years.
Should they send Spain home, Morocco would become only the second African team in history to record a five-game unbeaten run at the World Cup after Nigeria, who won two and drew three between 1982 and 1990, so there are plenty of incentives for the defensively-sound Moroccans to stun the Spaniards.
Creativity in abundance
When Paris Saint-Germain right-back Hakimi pinged a long ball forward for En-Nesyri to score his side's second against Canada, some were quick to label his assist as one of the best of the tournament so far, and the 24-year-old is not the only creative mind in the Morocco ranks.
The less said about Hakim Ziyech's fortunes at Chelsea the better, but the 29-year-old continues to shine at international level and has one goal and one assist to his name for the Atlas Lions at the 2022 World Cup so far.
Many will remember when Ziyech retired from the national team at just 28 following a bust-up with then-manager Vahid Halihodzic, but his reinstatement has been key to Morocco's success in Qatar, and his first World Cup goal was one to remember.
Ziyech was handed the ball on a plate from Canada goalkeeper Milan Borjan, who haplessly flapped at the attacker's lofted effort before it nestled into the back of the net, and the Chelsea man leads the way in several playmaking categories for the Atlas Lions.
Indeed, Ziyech has created a team-high seven chances, made 17 passes into the box and completed 43 carries so far, and he is certainly playing like a man trying to reinvigorate his club career amid links with a January transfer away from Stamford Bridge.
Read more on Morocco vs Spain
Click here to read our full preview for Morocco vs Spain
How Morocco could line up against Spain
How Spain could line up against Morocco
World Cup 2022: Morocco vs. Spain head-to-head record
World Cup 2022: Reasons for Spain to be confident of beating Morocco