Two early goals from Abdelaziz Barrada set hosts Morocco on their way to a 3-2 win over Egypt and a place in the men's Olympic football tournament next year.
Egypt have another chance to claim a place at the Games when they play Senegal in Saturday's third place play-off, at what is also the African Under-23 Championships.
Morocco will now play Gabon to decide who will be the first ever Under-23 African champions.
The two finalists have already booked their places at London 2012.
Getafe's Barrada opened the scoring in the first minute as Morocco broke down the left wing, and the 22-year-old fired home from inside the area.
He doubled the lead eight minutes later as he picked up a rebound off Egypt goalkeeper Ahmed El Shenawi, who failed to hold Adnane Tighadouini's initial shot.
Egypt then got back into the game, they had two chances cleared off the line and one hit the post, with the rebound saved by Younes Itri in the Morocco goal.
Mohamed Salah narrowed the deficit for Egypt 10 minutes before half-time when he cut in from the left and shot across the keeper into the bottom right of the goal.
Morocco had chances to extend their lead with El Shenawi saving well to stop Barrada getting a first-half hat-trick.
The hosts continued in the same vain early in the second-half and Barrada was again involved in Morocco's third goal.
He made a powerful run forward to feed Soufiane Bidaoui whose cross was slotted home by Younes Mokhtar.
With Morocco making several changes Egypt pushed forward and hit the post before they scored their second goal to ensure a close finish.
Mohamed Ahmed Abdel Baset scored Egypt's second as he made room for himself to shoot at goal.
Itri should have saved the shot that seemed to go underneath him.
Despite their defeat Egypt have two more chances to reach next year's Olympics.
They will qualify if they beat Senegal in Saturday's third-place play-off, with the loser having one more chance in a play-off against an Asian nation next year.