Seven-time Africa Cup of Nations champions Egypt virtually confirmed their place in the 2017 finals with a 1-0 home win against Nigeria, who now cannot qualify.
Their defeat, sealed by Ramadan Sobhy's goal, means Nigeria are out after the withdrawal of Chad had a major impact on Group G.
As long as Egypt do not lose 3-0 to Tanzania, the Pharaohs will be at the finals in Gabon, for what would be their first appearance since winning the tournament for the third time in a row in 2010.
Youssef El-Arabi scored both goals as Morocco confirmed their spot at the finals, becoming the first team to qualify, with a 2-0 home victory against 10-man Cape Verde.
Morocco had been banned from the tournament after they did not host the event in 2015, but won the appeal against their punishment in April.
South Africa are on the brink of elimination after a 0-0 draw with Cameroon left them in third in Group M, with just three points from four matches. Mauritania's trip to Gambia also finished goalless, with Cameroon still a point above Mauritania in top spot.
Algeria must wait to qualify after Faouzi Ghoulam's late penalty earned them a 3-3 draw with Ethiopia, opposition they had beaten 7-1 just on Friday in Group J.
Also in Group J, Tumelo Khutlang's decisive goal gave Lesotho their first points of the qualifying round with a 2-1 victory against Seychelles.
Liberia took a step towards qualifying with a crushing 5-0 defeat of Djibouti, a second-half hat-trick by William Jebor ensuring his side remain in control of Group A having taken nine points from four matches.
Group A's other nations, Tunisia and Togo, played out a 0-0 draw that leaves both teams tied on seven points, with Crystal Palace striker Emmanuel Adebayor unable to make a scoring return on his international comeback.
Rwanda boosted their chances of qualifying for only the second time with a 5-0 thrashing of Mauritius in Group H, while Democratic Republic of Congo took control at the top of Group B with a 2-0 win in Angola.
Reigning champions Ivory Coast lead the tight three-team Group I from Sudan after the teams played out a 1-1 draw.
Senegal's 2-1 win in Niger maintained their unbroken run of victories in Group K, while Burundi beat Namibia 3-1 away to keep their own qualification chances alive.
Burkina Faso and Uganda are tied on seven points at the top of Group D after a 0-0 draw in which Charles Kabore was sent off, while Guinea drew level with Swaziland in second place in Group L with a 2-1 away win over Malawi.
In Group B, Democratic Republic of Congo went top of the section with a 2-0 win in Angola.