South Africa survived a late penalty scare to knock pre-tournament favourites Morocco out of the Africa Cup of Nations and reach the quarter-finals.
Bafana Bafana were the better side and eventually ran out 2-0 winners over the 2022 World Cup semi-finalists - who had Sofyan Amrabat sent off in the closing stages after Achraf Hakimi had missed from the spot.
South Africa won just one group game to reach the knockout stages while Morocco had dominated Group F as they went in search of just a second AFCON title.
It was Hugo Broos' side, however, who would hit the front as Evidence Makgopa finished off a flowing move with a low strike just before the hour.
Morocco toiled for an equaliser and were presented with the perfect chance to level from the penalty spot with just five minutes remaining.
A VAR check saw South Africa defender Mothobi Mvala penalised for handball but Hakimi smashed the resulting spot-kick against the crossbar.
Things went from bad to worse for Morocco as they chased the game, with Amrabat sent off for tripping Teboho Mokoena as he bore down on goal.
The Manchester United loanee thought he had been given a reprieve as VAR intervened but instead they recommended referee Mahmood Ismail upgrade the second booking to a straight red.
To add insult to injury, Mokoena dusted himself off to brilliantly convert the resulting free-kick and send South Africa into a quarter-final clash against Cape Verde.

Mali profited from quick starts to each half as an own goal from Edmond Tapsoba and a strike by Lassine Sinayoko secured a 2-1 victory over Burkina Faso at the Stade Amadou Gon Coulibaly in Korhogo.
Mali scored within three minutes at the start of the match as the unfortunate Tapsoba turned the ball into his own net, and caught the Burkinabe cold again when they added a second two minutes after the break as Sinayoko netted his third goal of the tournament.
Burkina Faso pulled a goal back when Bertrand Traore slotted a penalty just before the hour-mark, but could not force an equaliser against a Mali side with a well-deserved reputation for a miserly defence, one of the reasons why they are among the tournament favourites.
Mali are seeking their first continental title and next face hosts Ivory Coast in a quarter-final that will be played in Bouake on Saturday.