Egypt and Gabon booked themselves places in the semi-finals of Africa's Olympic qualifying event in Morocco with wins on Saturday.
Gabon shocked Ivory Coast with a 3-1 win in Tangier while in Marrakesh, Egypt overcame South Africa 2-0.
Egypt finish top of Group B and will now play hosts Morocco on Wednesday in an all north African semi-final while a day earlier Gabon will play Senegal.
Gabon pipped Ivory Coast to second in the group thanks to a better head-to-head record as they both finished with four points, South Africa were bottom with two.
The Gabonese not only came from behind to win their game but played the final 35 minutes with 10 men.
Ivory Coast's Lacina Traore had several chances in the first half before eventually scoring just before the break.
He deflected in a shot from the edge of the area, as the Gabon defence failed to clear.
In a frantic start to the second half, Gabon scored twice in the opening five minutes as first Emmanuel Mba Ndong was on target and then Henri Junior Ndong fired home from the penalty spot.
Allen Nono, who was fouled for the penalty, was shown his second yellow card minutes later to leave Gabon defending their lead.
As Ivory Coast pressed forward they were caught out as Lionel Yacouya sealed the win with 12 minutes left on the clock.
There was also an exciting start to the second half in Marrakesh between Egpyt and South Africa.
Egypt's Mohamed El Neny scored with a powerful shot from the edge of the box into the top corner less than a minute after the break.
Fifteen minutes later a close range header from Marwan Mohsen sealed the win for Egypt.
South Africa did not give up and were only denied a goal by keeper Ahmed El Shenawi, who made several good saves.
The top three from this tournament, which is also the first ever African Under-23 Championship, qualify for the Olympics next year while the fourth placed side will take on an Asian side for another spot at the Games.