Nayef Aguerd's Morocco concluded their 2023 CAF Africa Cup of Nations campaign after a 2-0 defeat by South Africa in the round of 16 on Tuesday evening.
Aguerd and the Atlas Lions came through their group-stage campaign with seven points from three matches, but could not reach the last eight on a disappointing night at the Stade de San Pédro.
Following a goalless first half in the Ivory Coast, Evidence Makgopa struck the first goal of the game on the hour for Bafana Bafana, finding the net with a composed finish from a quickly-taken free-kick that caught out the Morocco defence.
Things went from bad to worse for Aguerd and his teammates as Achraf Hakimi struck the crossbar from the penalty spot with five minutes to go, then Sofyan Amrabat was sent-off for a foul and Teboho Mokoena netted the resulting free-kick in stoppage-time to confirm Morocco's exit.
The Atlas Lions, who had progressed as the top team in Group F after victories over Tanzania and Zambia and a draw against DR Congo, will hope to end their long wait for a second AFCON title when they host the tournament in 2025. Morocco's only previous triumph was back in 1976.
West Ham's involvement in the 2023 finals is now over, as Mohammed Kudus and Ghana were eliminated at the group stage.
However, DR Congo are still in contention, with former Hammers Grady Diangana and Arthur Masuaku hoping to get the better of Guinea in the quarter-finals on Friday. Hosts Ivory Coast and Sébastien Haller are still in, too, having defeated Senegal on penalties in the road of 16. The Elephants face Mali in the last-eight on Saturday.