Morocco won Group D at the 2019 Africa Cup of Nations after a 1-0 win over South Africa on Monday.
The Ivory Coast qualified as runners-up in the group, advancing with a 4-1 victory over Namibia.
South Africa will have to wait and see if they qualify as one of the best third-placed nations. Namibia finish bottom of the standings without a point.
Algeria completed a perfect run in Group C with a 3-0 victory over Tanzania, winning the group in the process.
Senegal's 3-0 win over Kenya guaranteed them passage into the next round.