South Africa's controversial and catastrophic African Nations Cup campaign came to a painful end here on Wednesday when a 1-1 draw with Morocco confirmed their elimination from the tournament.
The result means Morocco are Group D winners and will face north African neighbours Algeria in the quarter-finals in Sfax on Sunday.
Nigeria, who defeated Benin 2-1 in Sfax, are runners-up and must take on defending champions and old rivals Cameroon in Monastir, also on Sunday, for a place in the semi-finals.
The South African squad left the ground refusing to attend the post-match news conference, leaving Moroccan coach Badou Zaki to enjoy the limelight.
"We were very apprehensive in the first half," said Zaki.
"But we recovered to achieve a satisfying result. We are confident about facing Algeria and we will prepare very well for the game."
South Africa, bidding against Morocco to host the 2010 World Cup finals, took the lead through Patrick Mayo in the 29th minute only for Youssef Safri to equalise from the penalty spot nine minutes later.
After beating Benin 2-0 and losing 4-0 to Nigeria, South Africa knew they had to win this match by four clear goals if they were to make the quarter-finals - something they had never achieved before.
Coach April 'Styles' Phumo was also burdened by knowing that in the country's four previous appearances at the finals, they had never failed to reach the knockout stages.
He was forced to make a change in goal with Andre Arendse replacing the injured Emile Baron while veteran John Mosheou was dropped in favour of Tebeho Mokoena.
For the north Africans, skipper Noureddine Naybet was making his 100th international appearance.
Morocco, with two wins in two ahead of this clash, were sharpest in front of goal in the early exchanges with Youssef Hadji just failing to pick out Jaouad Zairi with only Arendse to beat.
It was Zairi who had the best opening after 18 minutes when a pass from Safri found him unmarked on the left-hand side of the penalty area, but the striker's drive was parried by Arendse.
South Africa grabbed a lifeline in the 29th minute thanks to a mistake by Morocco goalkeeper Khalid Fouhami who fumbled a cross from Siyabonga Nomvete allowing Mayo to slot the ball home from close range.
It was the first goal conceded by Morocco in the tournament.
However, the 1976 champions were back on level terms in the 38th minute when Zairi was brought down by Neil Winstanley in the area and Safri stepped up to bury the penalty kick in the corner.
Both sides cancelled each other out in the first half of the second period and as South Africa pushed more men forward in what was a lost cause, Zairi broke away from his marker and almost caused Winstanley to score an own goal as he chested the cross out of harm's way.
Nomvete hit the post in the dying moments to sum up his side's frustration.
South Africa had endured a traumatic build-up to the tournament sacking coach Shakes Mashaba the week before they arrived and having to do without key players Mark Fish, Shaun Bartlett, Quinton Fortune and Benni McCarthy who all refused to take part.
Wednesday's elimination also brought to an end a proud record.
They were champions in their first appearance in 1996, runners-up in 1998, third in 2000 and quarter-finalists in 2002.