Benin Republic produced a major surprise to beat Morocco 4-1 on penalties and book a quarter-final spot at the Africa Cup of Nations for the first time.
Mama Seibou hit the winning penalty to send 10-man Benin through after Khaled Adenon had been sent off in extra time.
In an incident-packed tie in Cairo, Moise Adilehou put Benin ahead before Youssef En-Nesyri equalized.
Morocco had a chance to win it with the last kick of normal time but Ajax’s Hakim Ziyech’s penalty struck a post.
Benin scored all their penalties in the shootout through Olivier Verdon, David Djigla and Tidjani Anaane before Seibou’s effort sparked wild celebrations on and off the pitch inside the Al Salam Stadium.
In what is only their fourth appearance at the Africa Cup of Nations, Benin will face the winners of Friday’s late last-16 tie between Uganda and Senegal in the quarter-finals on 10 July.
Morocco had progressed from the group stage with three wins and without conceding a goal.
Despite peppering Benin’s goal with 22 shots during the 120 minutes, they lacked cutting edge and are now on their way home from a tournament they were expected to do well in.
Benin, who advanced to the last-16 as one of the best four third-placed teams in the group stage, played the final 23 minutes of extra time with 10 men when Adenon was sent off for a second bookable offence.
En-Nesyri and Ziyech both forced saves from keeper Saturnin Allagbe before Benin took the lead through Adilehou’s close-range volley following a corner.
Morocco were gifted their equaliser, an horrendous mistake by Jordan Adeoti allowing Mbark Boussoufa to set up En-Nesyri to fire under Allagbe.