Ten-man Benin rode their luck to eliminate heavily fancied Morocco on penalties in an extraordinary upset in the opening match of the knockout stage of the Africa Cup of Nations on Friday.
Benin advanced to quarterfinals, after four successive draws, as they outscored Morocco 4-1 in the shootout after a 1-1 stalemate at the end of extra time in the last-16 tie.
The small west African nation survived a last-gasp stoppage-time penalty missed by Morocco and an extra-time dismissal to create one of the tournament's great upsets.
Defender Moise Adilehou opened the scoring to give Benin a shock 53rd-minute lead before Youssef En-Nesyri equalised after 76 minutes.
Morocco should have wrapped up the game in the last minute of stoppage-time penalty but Hakim Ziyech hit the upright with the last kick before extra time.
Benin played most of the added 30 minutes with 10 men after the dismissal of full back Khaled Adenon but held on to force the game into a shootout where Morocco missed twice, leaving Seibou Mama to convert the winning kick
The game had been a largely unattractive, stop-start affair before the goal from Adilehou woke up proceedings.
The centre back stretched out a foot to meet a corner that landed almost exactly on the penalty spot and squeezed the ball under Morocco goalkeeper Yassine Bounou to give Benin a shock lead.
Benin had only six efforts on target in their three group games, which were all drawn, and managed a solitary effort before the goal as they spent most of the time defending.
After Benin's goal, Morocco brought on Sofiane Boufal to boost the attack and within 60 seconds the substitute went narrowly wide with a diving header.
Benin held out under an onslaught for 23 minutes before a horror error by midfielder Jordan Adeoti, who got caught in possession just outside his own penalty area, allowing Mbark Boussoufa to set up En-Nesyri for the equaliser.
Adeoti then gave away a free kick on the edge of his own box in the 88th minute but Boussoufa's effort was expertly saved by a diving Allagbe.
Benin contrived to try and give away the game again when captain Stephane Sessegnon clumsily fouled Achraf Hakimi to concede a penalty four minutes into stoppage time but Ziyech sent his spot-kick wide.
Adenon was sent off seven minutes into extra-time, reluctantly leaving the field after a long argument and then going towards the Morocco bench in an attempt to confront Morocco coach Herve Renard as tempers frayed on both sides.
With three minutes left in extra time, Ziyech had another gilt-edged chance but blasted wide.
Benin meet the winners of Friday's last-16 tie between Senegal and Uganda in Wednesday's first quarterfinal.