Ghana and Mali scraped through to the African Cup of Nations semifinals on Sunday, as Tunisia and Gabon fell in agonizing fashion.
Ghana beat Tunisia 2-1 in extra time after goalkeeper Aymen Mathlouthi's blunder gifted the Black Stars a 101st-minute winner in a tense, bad tempered quarterfinal at Stade de Franceville that the Tunisians had controlled before Mathlouthi's decisive error.
Mali beat co-host Gabon 5-4 in a penalty shootout in the quarterfinal in Libreville after they were level at 1-1 at the end of 120 minutes.
Pierre-Emerick Aubameyang, Gabon's hero of the group stage, missed the decisive spot kick and dissolved into tears in the middle of a huddle of players as the home team's tournament ended in bitter disappointment.
Gabon won its first three games and was six minutes away from a first appearance in the semifinals, only for Cheick Diabate to equalize in the 84th and give Mali the chance to steal victory and a place in the last four in the shootout.
Ghana faces Zambia and Mali plays Ivory Coast in Wednesday's semifinals, leaving top-ranked African teams and tournament favorites Ghana and Ivory Coast still on course to meet in the Feb. 12 final.
"I think we were lucky there," Ghana striker Asamoah Gyan said after his team pounced on Mathlouthi's mistake. "You know in football anything can happen, luck also counts and you see the error the keeper made. I wouldn't blame him, but it happens in football."
Eric Mouloungui scored for Gabon from close-range after Aubameyang's cutback in the 55th minute at Stade de l'Amitie to seemingly continue a dream African Cup for the co-host.
But Diabate turned cleverly and forced his late shot under goalkeeper Didier Ovono to keep a stubborn Mali team alive at the tournament.
Aubameyang, who had also hit the post in normal time, then had his penalty saved by Soumaila Diakite in a gut-wrenching end for the co-host, allowing Mali captain Seydou Keita to step up and send his team through and Gabon out.
Mali's players, led by Keita, celebrated wildly on the running track around the field as the weeping Aubameyang was consoled by team mates and the previously rowdy, joyous Libreville crowd was silenced for the first time in two weeks.
At Franceville, the sparse groups of local supporters spent the buildup to the Ghana-Tunisia quarterfinal with their backs to the field watching the live broadcast of Gabon's game on giant TV screens at the stadium.
The crowd danced and sang at Stade de Franceville and a group of ball boys ran up and down behind one goal doing back flips and somersaults when Gabon took the lead.
Ghana led Tunisia in the 10th minute as John Mensah's rollercoaster ride of a tournament continued when he headed in at the far post from an Andre Ayew corner having scored and been sent off in his country's first game. He later left the field injured.
Saber Khalifa put Tunisia level, but despite holding the upper hand for large parts of the game the North Africans were undone by Mathlouthi's extra-time howler, which allowed Ayew to side foot into an empty net and Ghana to progress.
"It's a pity it ended like this for us," said Mathlouthi, who ironically won the game's fair play award. "It was my fault on every level."
Neither team deserved a fair play award as the match -- which was already physical -- descended into an ugly end when Tunisia's Aymen Abdennour was sent off for elbowing Ayew, leading to a shoving match near the corner flag between both sets of players.
Issam Jemaa made two reckless challenges in quick succession that went unpunished and Ghana's defense also mercilessly scythed down Youssef Msakni in the final minutes.
"They made a game look like a war," Ghana assistant coach Kwesi Appiah said.