La Roja finished second in Group E to set up a tie with their African counterparts, who fended off Croatia and Belgium to finish first in Group F.
Match preview
With the golden generation of Belgium under-performing and 2018 runners-up Croatia struggling to find a consistent attacking spark, Morocco took full advantage to claim a surprising first-placed finish in Group F with seven points from nine on offer.
Even in their goalless draw with Croatia, the plaudits largely went to Walid Regragui's men, who followed that point up with successive wins over Belgium and Canada to become one of only two African teams in the last 16 of the World Cup - the other being Senegal.
During their matchday three encounter with Canada, Hakim Ziyech took advantage of a blunder from Milan Borjan to chip the Canucks goalkeeper from distance in the fourth minute, and Youssef En-Nesyri put the icing on the cake before a Nayef Aguerd own goal gave the Canadians a slight glimmer of hope.
However, the Atlas Lions held on for the three points that would send them through to the knockout stages as group winners, and the 2022 tournament marks only the second time that Morocco have got this far, having been eliminated in the last 16 in 1986.
Now riding the wave of an eight-game unbeaten run in all competitions - during which time they have only conceded two goals - Regragui's men are out to become the first Morocco side to reach the quarter-finals, and they could also match continental history, as their four-game unbeaten run at the World Cup can only be beaten by Cameroon's five between 1982 and 1990 out of all the African nations.
Luis Enrique did not pull any punches as his side failed to hang on to a one-goal lead against Japan on the final matchday in Group E, where Alvaro Morata's 11th-minute opener ultimately counted for very little against Hajime Moriyasu and his perennial super subs.
Unai Simon let a long-range effort from Ritsu Doan seep through his gloves as Japan restored parity three minutes after the restart, and only three minutes later, Ao Tanaka prodded home the winner after Kaoru Mitoma had only just managed to keep the ball in play.
Many an argument was had over whether Mitoma had prevented the whole of the ball from going over the whole of the line, but the scoreline in the top left-hand corner was the only statistic that mattered, as Spain dropped to second in Group E and only bested Germany on goal difference.
Had La Roja placed first in the section, they would be tackling Croatia in the last 16, so finishing as runners-up may be seen as a blessing in disguise by some, but Enrique is under no illusions as to how difficult Tuesday's match will be.
Spain were eliminated from the 2018 World Cup in the last 16, but they have never suffered back-to-back exits at this point of the competition, and their tally of nine goals in the group stage was the joint-highest alongside England.
Morocco and Spain will be locking horns in the World Cup four years on from meeting in the group stages in Russia, where La Roja were indebted to a late Iago Aspas equalizer in a 2-2 draw, and a similarly close contest should be on the menu at the Education City Stadium.
Morocco World Cup form:
D
W
W
Morocco form (all competitions):
W
D
W
D
W
W
Spain World Cup form:
W
D
L
Spain form (all competitions):
L
W
W
W
D
L
Team News
Morocco number one Yassine Bounou, who felt unwell just before the win over Belgium and had to withdraw at the last second, was able to complete the full 90 minutes against Canada and will expect to form part of an untouched XI.
Achraf Hakimi - who provided a delightful assist for En-Nesyri's strike - is expected to be passed fit despite nursing some ankle problems, but the Paris Saint-Germain right-back was one of several starters not risked in full training on Saturday.
The likes of Ziyech, Sofyan Amrabat and Sofiane Boufal were also granted a well-earned rest, but there is nothing to suggest that the trio will not be given the green light for Tuesday's game.
As for Spain, Enrique was without the trio of Dani Olmo, David Raya and Cesar Azpilicueta in Friday's training session, although the former was just believed to have been rested after a gruelling group period.
However, Azpilicueta - who came off at half time against Japan - is dealing with pain in his calf, while the reasons for Raya's absence are yet to be explained, but Simon was always expected to be handed the gloves despite his error last time out.
Enrique was not afraid to hand starts to the up-and-coming duo of Nico Williams and Alejandro Balde against Japan, but Ferran Torres and Jordi Alba will expect to return to the first XI for the knockout stages.
Morocco possible starting lineup:
Bono; Hakimi, Saiss, Aguerd, Mazraoui; Ounahi, Amrabat, Sahiri; Ziyech, En-Nesyri, Boufal
Spain possible starting lineup:
Simon; Carvajal, Rodri, Laporte, Alba; Pedri, Busquets, Gavi; Torres, Morata, Olmo
We say: Morocco 1-2 Spain (a.e.t)
Morocco must harness every inch of their recent defensive resilience if they are to secure a first-ever appearance in the quarter-finals, and Regragui's attackers should also take confidence from La Roja's frailties at the back against Japan.