Achraf Hakimi missed a vital late penalty as much-fancied Morocco became the latest heavyweight casualty of the Africa Cup of Nations on Tuesday, suffering a shock 2-0 defeat to South Africa in the last 16.

Evidence Makgopa gave South Africa the lead just before the hour mark in the Ivorian coastal city of San-Pedro, but Morocco had the chance to draw level five minutes from time from the penalty spot.

Paris Saint-Germain star Hakimi squandered the opportunity, sending his kick off the top of the bar and over, before Morocco's misery was compounded as Sofyan Amrabat was sent off in stoppage time and Teboho Mokoena scored South Africa's second from the resulting free-kick.

Bafana Bafana go through to a quarter-final on Saturday in Yamoussokro against tiny Cape Verde, who have been one of the surprise packages of the tournament so far.

"We came here with the first aim of getting out of our group," said South Africa's Belgian coach Hugo Broos.

"We were delighted to do that but you can't be certain of going any further when you come up against Morocco.

"On Saturday we will once again be playing against a dangerous team and we can't make the mistake of underestimating them," he added of Cape Verde.

Meanwhile Morocco, World Cup semi-finalists in 2022, add to an ever-growing list of the continent's biggest names to have been knocked out of this Cup of Nations, 24 hours after champions Senegal were eliminated on penalties by hosts Ivory Coast.

Africa's top-ranked side were hoping to follow up their remarkable run to the last four in Qatar just over a year ago by winning their second AFCON title, 48 years after their first.

Instead they go the same way as Senegal, Tunisia, Algeria and Egypt in being knocked out, meaning none of the five top-ranked African nations will be present in the quarter-finals, as well as none of the four semi-finalists from the last edition.

"We are very disappointed because we came here with the ambition of winning," admitted Morocco coach Walid Regragui.

"Going out so early was not in our plans but this competition is very difficult.

"I take responsibility for everything that has happened. I never hide. Today I have failed," he added.

- Mokoena stars -

A South Africa side featuring eight players from the country's leading club Mamelodi Sundowns in their starting line-up took the lead in the 57th minute.

Themba Zwane released Orlando Pirates striker Makgopa, who finished past Morocco goalkeeper Yassine Bounou.

Yet a Morocco team missing the injured Hakim Ziyech and Sofiane Boufal were given a glorious chance to equalise late on.

They appealed loudly for a penalty when an Ayoub El Kaabi shot from point-blank range smashed into the arm of South African defender Mothobi Mvala.

The Sudanese referee initially waved play on before awarding the penalty after being called across to review the incident.

Up stepped Hakimi, the runner-up to Nigeria's Victor Osimhen for the most recent African footballer of the year prize, but he failed to convert from the spot.

Morocco were then reduced to 10 men in the second minute of injury time as Amrabat of Manchester United was dismissed for a last-man challenge on Mokoena as the South Africa midfielder charged towards the penalty box.

Amrabat was initially given a second yellow, a punishment that was upgraded to a straight red following a review.

The excellent Mokoena, one of the Sundowns contingent, then converted the resulting free-kick to finish off Morocco once and for all.