Egypt and Ivory Coast secured their place in the men's football tournament at next year's Olympic Games in Tokyo after reaching the final at the Confederation of African Football Under-23 Africa Cup of Nations in Cairo.
Hosts Egypt beat South Africa 3-0 with three second-half goals in the second semi-final at Cairo International Stadium.
It followed Ivory Coast needing a penalty shootout to defeat Ghana after the teams were locked at 2-2 after extra time.
The final is due to take place on Friday (November 22).
It will be preceded by the third-place playoff between South Africa and Ghana, the winner of which will earn the third Tokyo 2020 qualification berth for Africa.
Ramadan Sobhi fired Egypt into a 1-0 lead in the 59th minute following a penalty call against South Africa's Thendo Mukumela.
The home nation's victory was sealed thanks to a quickfire brace from Abdelrahman Magdy inside the last 10 minutes.
Goalkeeper Eliezer Ira Tape was the hero for Ivory Coast earlier in the day, saving three of Ghana’s spot kicks as Les Éléphants prevailed 3-2 in the penalty shootout and secured their place at the Olympic Games for only the second time in their history.
Youssouf Dao put Ivory Coast in front after 13 minutes after Hamed Junior Traorè's pass found him in a clear goalscoring position.
But shortly after half-time, Yaw Yeboah restored parity with a powerful shot having been picked out by Samuel Obeng's cross.
Dao thought he had won the game for Ivory Coast when he completed his brace six minutes from time with a diving header from Silas Gnaka’s delivery.
But deep into stoppage time, Evans Mensah received Owusu Kwabena’s cross to score from close range and send the match into extra time.
Neither side could add to their tally as the game headed to penalties, setting the stage for Tape to become the hero.