Their progression also guarantees qualification for this year's U20 FIFA World Cup, to be held in Chile from 27 September to 19 October.
Nigeria advanced after a tense goalless draw with Sierra Leone, eventually triumphing in a penalty shootout. Goalkeeper Ebenezer Ifeanyi Harcourt proved the hero, saving two spot-kicks as Nigeria converted all three of theirs.
Sierra Leone's Pierre Antoine Diatta Dorival and Mame Mor Faye saw their efforts denied, while Ousmane Konaté struck the crossbar.
Morocco edged past Sierra Leone 1-0 after extra time at the 30 June Air Defence Stadium. The deadlock was broken in the 115th minute via a cruel own goal by Amara Nmale Keita.
Sierra Leone had earlier gone down to ten men when Samba Juma Bah was sent off in the 98th minute.
Egypt also needed penalties to overcome Ghana after a thrilling 2-2 draw. Moamen Sherif Abdel Aziz Shehata Goweily scored twice for Egypt, with Ghana responding through Aziz Issah and a last-gasp penalty from Abdul Hakim Sulemana.
Ghana's Aaron Essel was dismissed in extra time before Egypt held their nerve in the shootout.
South Africa completed the quartet with a hard-fought 1-0 win over DR Congo. Thabang Mahlangu scored the decisive goal in the 109th minute, assisted by Shakeel April.