Barcelona star Seydou Keita converted the decisive spot-kick after the co-hosts' top striker Pierre-Emerick Aubameyang watched in disbelief as Mali goalkeeper Soumaila Diakite saved his effort. The Eagles' reward is a semi-final date with Côte d'Ivoire back at Libreville's L'Amitie stadium on Wednesday.
For Gabon, who were unbeaten in the first round, this was a cruel end to their campaign, reviving as it did memories of their defeat on penalties to Tunisia in their only other quarter-final appearance in 1996.
After his penalty, veteran Keita explained the feeling of firing his side through: "It was like a dream when I scored the winning penalty. I'm so proud to wear this shirt. I've won a lot with Barcelona but this is like winning the Cup."
Gabon's attempted charge into the last four was spearheaded by tournament joint-top scorer Aubameyang and Daniel Cousin, the captain, retaining his place. Mali welcomed back midfielder Samba Diakite from suspension, with Garre Dembele dropping to the bench, and keeper Diakite coming in for Oumar Sissoko.
Gabon go ahead
Among the crowd were the Gabon president and his First Lady, sporting as usual the Panthers' yellow shirt. The Panthers, displaying their customary zest and endeavour, were showing good early pace down the wings, especially Eric Mouloungui on the right, with the ever dangerous presence of Cousin waiting to pounce in the Mali box.
Aubameyang had the first gilt-edged chance appproaching the half-hour, beating the offside trap to flick the ball past Diakite only to see his effort hit the far post. As the first half wore on, Gabon began to look the more dangerous and the Mali keeper did well to keep tabs on Mouloungui's menacing low free-kick in the 42nd minute.
Gabon got the goal they deserved in the 55th minute when Aubameyang raced onto a high ball from the left, his back pass across the box falling to Mouloungui to slam past Diakite. That was the Nice forward's fifth and arguably most important international goal.
Seconds later down at the other end, Didier Ebang's gloves punched away Mali striker Modibo Maiga's attempt at an equaliser. As the game exploded, Cousin almost bagged Gabon's second on 58 minutes, the unmarked former Hull City forward's shot skimming past Diakite to hit the far post.
Diabate levels the scores
Mali coach Alain Giresse tried to shake things up after the hour, introducing striker Mustapha Yatabare for Abdou Traore, and shortly after Rohr surprisingly replaced captain Cousin with Fabrice Do Marcolino.
Mali were fighting for their Africa Cup of Nations existence and with six minutes left Cheick Diabate levelled not long after entering the fray in place of Samba Sow, the Bordeaux striker turning to shrug off his markers in the box and leaving Ovono with little chance.
Rohr knows Diabate only too well, having signed him during his days as coach of Ajaccio. The two sides were still deadlocked after extra time, after Keita shot high in the last seconds, and Algerian referee Haimoudi Djameil pointed to the spot for the nerve-jingling climax.
After Diakite had saved Aubameyang's kick it was left to Keita to step up and coolly slot home Mali's fifth to send the Eagles' spirits soaring, while the Gabon team rushed to console a tearful Aubameyang.