Morocco stunned Spain with a penalty shootout win to reach the World Cup quarterfinals after playing to a 0-0 draw on Tuesday.

Spain dominated possession in the first half but could not find a way past a resolute Morocco defence. The best chance of the half came when Morocco defender Nayef Aguerd headed over from close range.

Stream on ESPN+: LaLiga, Bundesliga, more (U.S.)

The 2010 World Cup champions enjoyed more than 75% of possession and completed almost 800 passes but could not find a breakthrough inside 90 minutes, sending the game to extra time. Morocco had the better chances as they squandered a pair of one-on-ones and, with the scores still level, a penalty shootout was required.

The times were divided in experience — it was Morocco’s first shootout at a World Cup finals and Spain’s fifth — but Morocco goalkeeper Yassine Bounou turned hero, watching Spain first spot kick hit the post before saving their next two efforts to help the North Africa side to a 3-0 victory on penalties.

The result means Morocco advance to the World Cup quarterfinals for the first time, where they face the winner of Portugal and Switzerland, who play later on Tuesday.

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

Information from Reuters contributed to this report.