Moise Adilehou forced home at a corner early in the second half to put Benin on course for a shock win but Youssef En-Nesyri equalised for Morocco before Ajax star Ziyech blew the chance to snatch victory by striking the post from the spot in the 96th minute.
Benin were forced to play most of extra time a man down after Khaled Adenon received a second yellow card for dissent, but they prevailed 4-1 in the shootout following misses by Sofiane Boufal and En-Nesyri to set up a clash with Senegal or Uganda on July 10 for a spot in the semi-finals.
With this, Benin have now played a total of 13 games in the history of the African Cup of Nations without winning a single game. This year they only scraped through to the knockout rounds on the back of three draws after holding both Ghana and reigning champions Cameroon.
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.
Holders Cameroon played out their second successive 0-0 draw at the Africa Cup of Nations when they were held by Benin on Tuesday, meaning they finished second in their group and must face neighbours Nigeria in the round of 16.
The result, in another disappointing Group F match, also meant that Benin qualified for the knockout stages as they made it past the group stage of the competition for the first time at the fourth attempt.
Cameroon finished with five points but were edged into second place on goals scored by Ghana who beat Guinea-Bissau 2-0.
Benin, who drew all of their matches, finished with three points and their goal difference of zero was enough to ensure they will finish as one of the four best third-placed teams.
Cameroon’s Yaya Banana was closest to breaking the deadlock when he headed against the crossbar in the 82nd minute but, overall, it was another uninspired performance from the Indomitable Lions.
“I am very satisfied because we are in the next round although we are disappointed because we wanted to win the match,” said Cameroon’s Dutch coach Clarence Seedorf.
“We have to improve a few details, especially in the last part of the field, to be a bit smarter, create more chances,” he added. “That is football, we need to accept that the opponents did a good job in defending, we pushed the whole match.”
His opposite number Michel Dussuyer, a Cup of Nations stalwart coaching his third different side in the African tournament, admitted his team had set out for a draw.
“Everybody has made a sacrifice for tonight because we were looking for this point, everybody has fought hard,” said the Frenchman.
“We didn’t play our best football tonight. We defended well, we tried to reduce the spaces and stop them exploiting their speed in attack.”
It was pretty much all Cameroon in the first half.
Karl Toko Ekambi had a clear chance after five minutes but sent his header over the bar after rising to meet Collings Fai’s cross.
Ambroise Oyongo saw his low drive tipped past the post by Saturnin Allagbe, who also did well to tip away a low drive from Eric Choupo-Moting, while Oyongo was not far away with a rising drive just before halftime.
Benin offered little threat although a low free kick into their area caused panic as Oyongo was forced to dive between two defenders to intercept before keeper Andre Onana grabbed the ball.
The second half became increasingly scrappy. Cameroon tried to get around the massed Benin defence by chipping balls over the top but the ploy did not work and they began to run out of ideas.
Benin, sensing they were near the point they needed, fell back into defence and had only one real scare when substitute Banana headed against the bar from Pierre Kunde Malong’s cross.
Benin and Guinea Bissau completed a hat-trick of goalless draws at the Africa Cup of Nations on Saturday with a stalemate that left both teams waiting for their first-ever win at the competition.
After Angola and Mauritania began the day with a 0-0 draw in Group E and Cameroon and Ghana also failed to produce a goal in Group F, Benin and Guinea Bissau rarely looked like breaking the sequence in a scrappy match short of clear chances.
A draw always seemed the logical result in the Group F game given their respective historical records at the finals.
Benin, taking part for the fourth time, have drawn two and lost eight of their previous 10 matches in the competition while Guinea-Bissau, at their second finals, went into the match with a record of three defeats and a draw in four games.
Benin have two points from two games, level with Ghana, while Guinea-Bissau have one and face Ghana in their final game. Cameroon lead the group with four.
Steve Mounie went closest to breaking the deadlock when he sent a header over the bar in the 75th minute.
Jordan Adeoti sent an early effort into the side-netting for Benin and also had the best chance of the first half when he burst down the left but was pushed wide and his shot was saved by Jonas Mendes.
Piqueti and Pele were lively for Guinea Bissau, who have half their squad based in Portugal, and Sori Mane had their best effort when he won the ball, galloped forward but saw his shot deflected over.
“Our team did their job, we tried to cut their lines, we created some chances of our own and I think a draw was a fair result,” said Guinea-Bissau coach Baciro Cande.
“It is very difficult for us to qualify but in football everything is possible and our target is to get to the round of 16.
“We know Ghana are very powerful, very strong but we will play our normal game, with no pressure.”
Underdogs Benin hit back to secure a 2-2 draw with 10-man Ghana after the Black Stars had a player sent off for time-wasting in bizarre circumstances at the Africa Cup of Nations on Tuesday.
Michael Pote gave Benin a shock second-minute lead in the Group F match before goals from brothers Andre and Jordan Ayew put Ghana 2-1 ahead at halftime.
But Ghana were stunned in the 55th minute when defender John Boye, already booked, stepped up to take a free kick inside his own half, moved away to let a team mate take it and was given a second yellow card.
Pote then equalised for Benin with his second of the night in the 64th minute.
Benin, taking part in the tournament for the fourth time, had lost eight and drawn one of their nine previous games at the finals but more than held their own against the four-times champions.
The Squirrels were in front after two minutes, Pote racing onto a ball threaded through from midfield before slipping past his marker and firing his shot under Ofori.
Ghana replied with a goal from their first attack seven minutes later. Jordan Ayew ran onto a pass over the top and laid the ball off to his brother Andre who made space before firing a snapshot into the net.
Ghana, looking more dangerous, went ahead three minutes before halftime. Kasim Adams picked out Jordan Ayew from the halfway line and the younger of the two brothers slipped passed Olivier Verdon and fired into the top corner from the edge of the penalty area.
At that point, the game seemed to be up for Benin but Boye’s dismissal changed the complexion of the game, prompting Ghana coach Kwesi Appiah to bring off Samuel Owusu — himself a first-half substitute for the injured Thomas Agyepong — and bring on Jonathan Mensah.
Benin’s equaliser came from a short corner as Pote diverted Cebio Soukou’s low cross into the net.
Both teams continued to look for the winner and Thomas Partey was close for Ghana with a ferocious 25-metre free kick which Fabien Farnolle did well to push away.
Benin could also have snatched it in injury time as Jodel Dossou’s cross from the right picked out Steve Mounie but he sent his header over the bar.
Following the opening round of games, Cameroon top the group with three points following their 2-0 win over Guinea Bissau earlier on Tuesday.