Gabon struck in the last minute of extra time to claim a 1-0 victory over Senegal and qualify for the U-23 African Championship final, securing the first African berth at next year�s London Olympic Games.
Andre Pocko Biyogho scored the invaluable winner in the 119th minute to give Gabon a surprise victory.
He headed home following a corner as Gabon, who finished second in Group B behind Egypt, became the first African side to book a ticket to London.
Egypt and hosts Morocco meet in the other semi-final game on Wednesday.
The African Championship winners, runners-up and third-placed team will directly qualify for the Olympics while the fourth-placed side will have to overcome an Asian representative in a playoff to go through.