Ramadan Sobhy's second-half strike all but secured Egypt's place at the 2017 Africa Cup of Nations as a 1-0 win ended Nigeria's hopes of reaching Gabon.
Chad's withdrawal from qualifying Group G, reportedly for financial reasons, meant all points against the nation were discarded and that no best runners-up spot would be available, leaving Nigeria with a must-not-lose situation in Alexandria.
But Egypt, whose own preparations were hindered by an election-rigging scandal engulfing the country's football association, were the far superior side and Ahmed Hegazy and Ramy Rabia missed great first-half chances.
Hector Cuper's men were not to be denied, though, and Sobhy's soft effort had enough to beat Nigeria goalkeeper Daniel Akpeyi to earn the three points.
Nigeria can now no longer overtake Egypt as they are five points adrift with just one match to play, while Egypt are also six points clear of Tanzania - who have two games left - with a far superior goal difference.
Egypt started the brighter and Hegazy should have done better when he headed Mohamed Salah's free-kick wide when unmarked in the box.
Odion Ighalo was wayward with a half-volley in the penalty area in Nigeria's best chance of the half, but Egypt continued to press and captain Abdallah Said dragged an effort wide of the right-hand post.
Akpeyi was then on hand to make a smart stop from Ibrahim Salah's edge-of-the-area shot, before tipping Rabia's flicked header over the crossbar.
Arsenal midfielder Mohamed Elneny struck over the bar for Egypt shortly after the restart, while the lively Victor Moses was denied by Hegazy's timely block at the other end.
The hosts' pressure finally told in the 66th minute, though. Salah's corner was not dealt with and Sobhy's tame shot squirmed through several Nigeria defenders and under a despairing Akpeyi, who could have done better.
Nigeria piled on the pressure in the closing stages and Moses saw a 20-yard left-foot effort rebound cruelly off the right post but, despite their best efforts, Egypt held on for the win.
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 Islands.
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 last week 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 Congo DR took control at the top of Group B with a 2-0 win in Angola.
Reigning champions Cote d'Ivoire 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.