Egypt and Algeria failed to qualify for the 2018 African Nations Championship (CHAN) finals in Kenya after suffering aggregate defeats to Morocco and Libya respectively.
Morocco beat Egypt 3-1 in Rabat on Friday to win the tie 4-2 overall.
Libya held Algeria to a 1-1 draw in Sfax to go through to the finals with a 3-2 aggregate victory.
The match was played in Tunisia for security reasons.
The Moroccans clinched their place thanks to three second-half goals from Jawad Yamiq, Abderrahim Maqran and Badr Belhrouz.
Hamid Hossam scored a late consolation goal for Egypt, who were making their debut in the biennial competition for home-based footballers.
Algeria knew they had to score at least twice against Libya to survive having lost the first leg 2-1, and they took the lead midway through the first half when Sofiane Bendebka scored off a rebound.
But first-leg match-winner Muaid Ellafi levelled on the stroke of half-time and Libya held on to take the aggregate win.
Despite CHAN matches only featuring locally-based footballers the games have full international status and count toward the monthly Fifa rankings.