The result puts Gabon, missing captain Pierre-Emerick Aubameyang with ‘heart lesions’, on the verge of the last 16.
Andre Ayew had put Ghana in front in the 18th minute, but his strike was cancelled out by Jim Allevinah’s 88th-minute equaliser.
Daniel-Kofi Kyere had gone down following a challenge inside the Gabon half but, from the resulting throw-in, Guelor Kanga played the ball to Allevinah, who struck a low left-footed shot across Jojo Wollacott and into the bottom right-hand corner.
Ayew protested to referee Lahlou Benbraham about the goal to no avail and scuffles broke out when Gabon celebrated at full-time.
Ghana substitute Benjamin Tetteh was shown a red card after the final whistle for his part in the on-pitch melee.
Scrappy game leaves Ghana needing final-game victory
Ghana were under pressure in the opening moments of the game, with Swindon Town keeper Wollacott and his defenders struggling with communication, but the Black Stars grabbed the lead when Ayew put them in front with a magnificent strike.
Receiving the ball well outside the area, he controlled it, made space and fired home for his 10th goal at Nations Cup finals.
Ayew, sporting a prominent dressing over his left eye from the head injury he suffered in his side’s defeat by Morocco, celebrated almost angrily as he tried to inspire his team-mates.
After their opening flurry, the Panthers rarely created much until almost an hour played, when Wollacott made a smart save to deny Allevinah, who was inches short of poking home.
The game barely flowed and neither side was able to take a grip, but it was played in a lively atmosphere in Yaounde with fans of both teams making themselves heard.
Gabon striker Aaron Boupendza, scorer of their winner against Comoros, had a couple of shots blocked.
The Panthers need a point to reach the last 16 when they face Morocco in their final group match on Tuesday while Ghana will take on winless Comoros, needing victory to remain in with a chance of progressing.