With the scores locked at 1-1 after extra time, Libya ran out 5-3 winners after a penalty shootout.
Gabon’s second penalty taker Alain Djissikadie Mpaga had his attempt saved which proved to be the difference between the two teams.
Earlier, Gabon were the more aggressive side, dominating possession as the Libyans looked content to sit back and adopt a defensive approach, rarely throwing numbers forward.
The west African side were close to a goal on 14 minutes, when Samson Mbingui smashed the ball into the crossbar with a superb left-footed free kick.
The north Africans’ game plan paid off five minutes after the restart. Abdelsalam Omar sprang the off-side trap and ran onto the ball before calmly lobbing it over the head of Parfait Bitseki Moto to make it 1-0 to Libya.
The Panthers were able to restore parity, from the spot, as substitute Daniel Cousin slotted home a 73rd minute penalty after Abdelrahman Fetori upended Lionel Yackouya.
The sides ended the regulation 90 minutes locked at 1-1, and extra-time ensued. The first half featured a number of players calling for stretchers, and the game lacked a real flow with the disruptions.
As the match progressed to extra time, the north Africans began to find an extra gear towards the end of the first half of additional play.
Mohamed Ghanudi, for Libya, was denied by the woodwork in the 102nd minute when his rocket of a 20-yard drive smashed into the crossbar.
Moments later, Moto made an acrobatic save to keep out Fetori’s audacious volley from a tight angle.
However, the win for Libya had them rewarded with a semi-final duel with Zimbabwe as they aim for the finals.