LIBREVILLE, Gabon (AP) – Bruno-Zita Mbanangoye scored from a stoppage-time free kick in Gabon's dramatic 3-2 win over Morocco on Friday to put the co-hosts into the African Cup of Nations quarterfinals and send the Group C favorite crashing out of the tournament.
Mbanangoye's curling right-footed effort decided a frantic game in which Gabon had come back from 2-1 down with two goals in a minute before conceding a 90th-minute equalizer from a penalty.
But Gabon wouldn't give up, and Mbanangoye's strike in the fifth minute of stoppage time ensured a barely believable finish.
Tunisia also progressed to the last eight following its earlier 2-1 win over Niger and with Gabon's victory, while Morocco joined Senegal in a shock first-round exit.
Gabon President Ali Bongo lived every moment of his team's rollercoaster ride at Stade de l'Amitie, first sitting subdued in his chair when the co-host was 1-0 down, then hugging two officials in the VIP section and jumping up and down in celebration when 2-1 up.
At the end, he could only stand and stare ahead with a beaming smile on his face following the unpredictable African Cup's craziest game yet.
Morocco thought it had just managed to stay alive in the tournament when captain Houssine Kharja sent a high-pressure spot kick into the bottom right corner, his second goal bringing the teams level at 2-2 in the last minute of normal time.
But there was one more jaw-dropping moment as Mbanangoye's free kick sent the stadium - and the country - into raptures and put the team into the last eight for only the second time in its history.
No one could have predicted there could be more excitement after star striker Pierre-Emerick Aubameyang had canceled out Kharja's first-half opener in the 77th minute and veteran forward Daniel Cousin - on as a substitute - poked the ball into the net barely a minute later to turn a 1-0 deficit into a 2-1 lead.
Yet there was.
Charly Moussono's handball gave Morocco a lifeline, only for it to be cruelly yanked away by Mbanangoye's intervention at the very last moment.
In an act that almost faded from memory, Kharja cleverly turned away from two defenders to hit a left-footed shot into the bottom right corner for his 25th-minute goal that settled Moroccan nerves.
But Morocco tried to protect its lead in the second half and, with Gabon threatening time and again, Aubameyang's volley from near the penalty spot after a poor defensive header across the area brought the home team level.
Cousin scored what the packed stadium presumed was the winner straight afterward. It brought some home fans spilling out the stands and onto the edges of the pitch in wild celebrations, and forward Eric Mouloumbui was even floored in the melee.
Gabon then had a chance to lead 3-1 but sent a shot from right in front over the crossbar in the 85th minute.
Morocco coach Eric Gerets appeared resigned to the turnaround, biting his lip and standing dead still on the sidelines looking straight ahead.
But his team found the spirit to push forward again, and was rewarded when Younes Belhanda's shot struck Moussono's arm as it headed toward goal. Kharja sent opposing captain Didier Ovono the wrong way in the Gabon goal for 2-2.
Gabon then launched a final assault on Morocco's goal as the five minutes of added time ticked away and won a free kick on the left corner of the penalty area.
Mbanangoye hit it perfectly, sending it sailing over the defensive wall and curling away from goalkeeper Nadir Lamyaghri to nestle in the top left corner.