Morocco captain Medhi Benatia was on target in a 2-0 over Ivory Coast to book their spot in Russian Federation.
Tunisia also booked their spot at Russian Federation 2018 with a tense 0-0 draw against Libya.
The Ivorians continued to pressurise the visitors with 10 minutes to play but they lacked the sense of urgency for a team that needed three goals in the remaining minutes to qualify.
West Africa has dominated Africa's contingent at the World Cup in recent years but some of its big names missed out this time: Ivory Coast, Cameroon and Ghana, all African champions multiple times, won't be in Russian Federation.
Juventus defender Medhi Benatia was on target as Morocco qualified for the World Cup for the first time since 1998. In case of qualifying to the World Cup in Russian Federation, each player will receive $ 100,000.
They endured a scare when Gervinho missed a good chance for the hosts but Nabil Dirar's cross evaded keeper Sylvain Gbohouo in the 25th minute to put the guests in front.
It is another achievement for Morocco's French coach Herve Renard, who famously won the Africa Cup of Nations with Ivory Coast in 2015.
Tunisia survived some nervous moments in Rades as Libya finished strongly.
Tunisia finished top of the group on 14 points, just one point ahead of second-placed Congo Democratic Republic who defeated Guinea 3-1. The Tunisians held on for the draw, though, and it turned out to be a precious point.
Morocco have remarkably qualified from Group C without conceding a single goal.