In a spirited performance that resonated with the Arab world, Morocco Tuesday stunned former winners Spain in a dramatic penalty shootout in their FIFA World Cup Qatar 2022 Round of 16 clash.

Achraf Hakimi, the Madrid-born defender, found the net with calmest of ease on the fourth penalty to take Morocco to their maiden quarter-finals berth in World Cup history.

The packed Education City Stadium erupted in absolute joy as Hakimi's shot hit the net giving Morocco an unassailable 3-0 lead in the penalty shootout following a goalless regulation play of 120 minutes separated by extra time.

Morocco goalkeeper Yassine Bounou, who plays for Spain's Sevilla, saved spot-kicks from Carlos Soler and Sergio Busquets after Pablo Sarabia had hit the post and Hakimi, a product of the Real Madrid youth system, held his nerve to earn his team a quarter-final against either Portugal who crushed Switzerland 6-1 Tuesday.

Morocco Tuesday became only the fourth African nation to reach the last eight of the tournament, 12 years after Ghana did so in South Africa in 2010.

After a scrappy match finished 0-0 after extra time with few shots on target for either side, Morocco fed off the raucous support of their red-clad fans in the shootout as Spain crumbled.

Spain enjoyed more than 75% of possession and completed almost 1000 passes but Morocco caused problems for them on the counter-attack and goalkeeper Unai Simon made some good saves.

"We fought and made the Moroccan people happy, we made history and Morocco deserve it, Moroccan people made us united on the pitch," coach Walid Regragui said Tuesday.

Morocco defender Jawad Yamiq was proud of his team's performance.

"We honoured the Arab and African football, coach Regragui gave us the confidence that we needed in this game, a big boost in morale," he said. "We knew that Spain depend on their ball possession and we played with that in mind. They didn't impose any danger."

It was the fourth time Spain have been knocked out of the World Cup on penalties and the second in a row.

It was a huge blow for Luis Enrique's team, who arrived in Qatar as one of the favourites after reaching the Euro 2020 semi-finals and the Nations League final last year.

"We completely dominated the match, it's a shame it went that way," the Spain coach told TVE Tuesday. "It's the most difficult thing, playing against a team like Morocco who are hard workers. The penalties cost us, but I am very proud of the team and all the players. I’m very sorry about the result but I congratulate Morocco."

In the day's other clash, 2016 Euro champions Portugal crushed Switzerland 6-1 at Lusail Stadium in a game that saw Cristiano Ronaldo on the bench.

Goncalo Ramos scored the first hat-trick of the 2022 World Cup as Portugal powered towards a place in the quarter-finals with a one-sided mauling of Switzerland.

The 21-year-old Ramos, named in the starting line-up ahead of veteran star Ronaldo, struck in the 17th, 51st and 67th minutes.

Benfica forward Ramos - making his first international start - was substituted for Ronaldo with just under 20 minutes of regulation time remaining at the Lusail Stadium.

Earlier Pepe, the stand-in captain, added Portugal's second just after the half hour mark when he beat two defenders in the air to head home a corner. Raphael Guerreiro scored one in the 55th minute while Rafael Leao scored the sixth in injury time (90 +2).

Portugal will face Morocco in the quarter-finals on Saturday.