Gabon have reached the quarter-finals of the Africa Cup of Nations with a dramatic 3-2 win over Morocco.
The result also means that Morocco have been knocked out of the competition.
Morocco took the lead in the 24th minute when Houssine Kharja collected Younes Belhanda's pass before slotting in from 12 yards.
In a half of few chances, Pierre-Emerick Aubameyang could have equalised minutes later, but he was unable to guide his shot on target.
Daniel Cousin had a fierce shot parried by the Moroccan goalkeeper just after the restart before Bruno Managa blasted over when he should have done better.
Gabon found an equaliser with 15 minutes to play as Aubameyang volleyed in from inside the area.
Their lead was doubled two minutes later as Cousin was on hand to convert Aubameyang's pass.
Levy Madinda could have sealed the win in the final five minutes, but a lack of composure saw his shot sail over the bar from 10 yards out.
Morocco grabbed an equaliser in the final minute when Charly Moussono was deemed to have handled Belhanda's shot. Kharja calmly finished to earn his side the draw.
However, there was still time for late drama as the substitute Bruno Zita fired in a free kick from 20 yards in the eighth minute of injury time.