Having been World Cup semi-finalists in Qatar last year, the Atlas Lions were fancied to go all the way on their own continent. But without one of their leading attackers, Hakim Ziyech, they couldn't break down their resilient last-16 opponents and instead conceded two goals in the second half.
The opener was scored by Evidence Makgopa in the 57th minute, when VAR eventually confirmed he was onside for his low finish past Yassine Bounou.
The video system came into play twice more in a gripping conclusion to the match, firstly giving Morocco the chance to save themselves in the 85th minute as Mothobi Mvala was penalised for blocking Ayoub El Kaabi's shot with his hand.