Morocco beat Spain on penalties to reach the last eight of the FIFA World Cup ©Getty Images

Morocco beat Spain on penalties to reach the FIFA World Cup quarter-finals for the first time ever and will face Portugal, who were irresistible in dispatching Switzerland 6-1.

Spain failed to score all three of their penalties at Education City Stadium, setting up a scenario where Madrid-born Achraf Hakimi clipped home the decisive spot kick.

Pablo Sarabia hit the post, while Sergio Busquets and Carlos Soler saw their penalties saved by Morocco goalkeeper Bono.

Spain had dominated possession as expected but were frustrated in normal time and extra time by a stubborn Moroccan performance.

Sarabia also hit the post late on for Spain in extra time, but Morocco had chances of their own, with Nayef Aguerd and substitute Walid Cheddira both squandering great opportunities.

Spanish manager Luis Enrique had claimed before the match that his side had taken 1,000 penalties in training to prepare for a shootout, but there was little evidence of it helping as they wilted under the pressure.

Morocco's victory sparked celebrations across the Arab world and in European cities such as Paris ©Getty Images
Morocco's victory sparked celebrations across the Arab world and in European cities such as Paris ©Getty Images

This is the second tournament in a row where Spain have been knocked out on penalties in the round of 16.

The Spanish have also now lost four of their five World Cup shootouts.

Morocco, who have been one of the teams of the tournament and boast an impressive following in Qatar, are the last team left from outside of Europe and South America.

Portugal await following their free-flowing victory over Switzerland which vindicated manager Fernando Santos' decision to drop Cristiano Ronaldo.

Gonçalo Ramos, who took Ronaldo's place, scored the tournament's first hat-trick at Lusail Iconic Stadium in arguably the most outstanding team display so far seen this World Cup.

Gonçalo Ramos, right, scored the World Cup's first hat-trick as Portugal marched into the quarter-finals ©Getty Images
Gonçalo Ramos, right, scored the World Cup's first hat-trick as Portugal marched into the quarter-finals ©Getty Images

The first was an emphatic left-foot finish from a tight angle, the second a close-range prod and the third a deft chip.

Between those goals Pepe headed in from a corner, Raphaël Guerreiro slammed home after being set up by Ramos and Manuel Akanji had pulled one back for the Swiss.

Portugal's sixth goal came via Rafael Leão and a splendid curling shot.

Portugal have never won the World Cup and last reached the quarter-finals in 2006.

Morocco and Portugal's quarter-final clash is set for Saturday (December 10).