The winner came in the final minute of extra time in Moroccan city Tangiers after a drab match with Andre Biyogho Poko of Bordeaux heading home a corner from Alexander Ndoumbou of Orleans.
Rank outsiders when the tournament kicked off ten days ago, the Baby Panthers bounced back after a loss to Egypt by holding South Africa and defeating Côte d’Ivoire to finish as Group B runners-up.
Senegal started as slight favourites to reach the final having beaten Nigeria and Morocco to top Group A, but were lucky not to fall behind early in the first half when the Gabonese had a goal from Romuald Ntsitsigui disallowed.
Senegal squandered a great chance when unmarked Kara Mbodj blazed over in second-half stoppage time and grounded 17-year-old Gabon goalkeeper Nick Moundounga used his feet to foil Dame Diop in extra time. The Senegalese did get the ball in the net after 112 minutes, but the goal was ruled offside.
CAF president Issa Hayatou was among the crowd inside the Tangiers Stadium and there was little in the way of goalmouth action with the teams concentrating more on not losing than winning.
Morocco host Egypt in the other semi-final in Marrakech on Wednesday with another place at the London Olympics up for grabs, while the losers will face Senegal on Saturday for third place and a third ticket to the games.
Whichever country loses the play-off gets yet another chance to qualify for the quadrennial multi-sport showcase in a play-off next April against an Asian nation.
Africa has a proud record in recent Olympic tournaments with Nigeria striking gold at the 1996 Atlanta Games, Cameroon repeating the feat four years later in Sydney and Nigeria finishing runners-up at the 2008 Beijing Games.