
Morocco, who had Sofyan Amrabat sent off late on, were among the favourites at the tournament in the Ivory Coast, but their continental curse continues and they remain without a Cup of Nations title since 1976, this time undone in the muggy heat of the Laurent Pokou Stadium.
South Africa led in the 57th minute when midfielder Themba Zwane, so often the creative fulcrum of the side, slipped a pass through to tall striker Makgopa and he calmly slid the ball past goalkeeper Yassine Bounou, before Mokoena fired in a superb late freekick.
Morocco had a chance to level with the score at 1-0 when they were awarded a penalty, but Achraf Hakimi hit the crossbar and it will be South Africa who play Cape Verde in the quarterfinals in Yamoussoukro on Saturday.