LIBREVILLE (AFP) - Gabon made it into the Africa Cup of Nations quarter-finals after a classic and almost surreal 3-2 win over Morocco here on Thursday.
Morocco, with an injury time penalty, believed they had done enough to keep their Cup hopes alive, but that wasn't counting on Bruno Mbanangoyes's curling freekick in the final second of the eighth minute of stoppage time of a remarkable encounter.
Gabon had been on the brink of winning in normal time after second half goals from Daniel Cousin and Pierre-Emerick Aubameyang had put them in command after Houssine Kharja's opener.
But, as the stadium announcer urged the 40,000 partisan supporters to "remain calm, remain calm" Kharja appeared to have spoiled Gabon's night when stepping up to coolly convert the 91st minute spotkick awarded for Charly Moussono's handball.
Then along came Mbanangoye to seal all three points which not only put Gabon into the last eight but Tunisia too, who earlier defeated Niger 2-1.
Morocco and Niger are heading home.
Morocco coach Eric Gerets made four changes from the opening defeat to Tunisia.
The Belgian chose to start Arsenal striker Marouane Chamakh, laid low with a stomach bug this week, on the bench, where he was joined by Noureddine Amrabat, Mbark Bousoufa and Ossama Assaidi, recovering from an Achilles tendon injury.
His Gabon counterpart Gernot Rohr adopted the policy 'if it ain't broke don't fix it' by naming the same side that saw off Niger 2-0 on Monday.
As they had done in their opening match Rohr's co-hosts chased and harried their north African visitors whose Michael Basser had Gabon's defence on the rack early on only to blast his shot off target.
On 24 minutes Morocco injected some much needed life into their campaign when Younes Belhanda found Kharja in the middle of the area, the Fiorentina midfielder losing his marker and shooting low and left-footed past Gabon keeper Didier Ovono Ebang.
At the restart Gabon introduced Cousin for Stephane Nguema and Morocco replaced Youssef El Arabi with Noureddine Amrabat.
Cousin's introduction almost paid immediate dividends when the former Hull City striker raced onto a cute backpass from Aubameyang over in the righthand corner, his venomous shot smacking off keeper Nadir Lamyaghri's outstretched hands.
On the hour mark Remy Ebanega was stretchered off with blood pouring from his mouth, the defender returning to the field of battle with a bandaged head.
Queen Parks Rangers striker Adel Taarabt then entered the fray as Morocco tried to kill the game off.
But Gabon got the equaliser they deserved in the 77th minute when Aubameyang volleyed in right-footed in a move begun by a long throw in from the left touchline.
Seconds later Cousin sent the 40,000 crowd into ecstasy when bagging what he and the rest of his teammates thought was the winner, skilfully turning to lose his marker, the ball going in off the right post.
But the game had only just begun, as Kharja converted from the spot and then Dinamo Minsk midfielder Mbanangoye became a national hero.