Nigeria shattered South Africa's dreams of progressing beyond the group stages of the African Nations Championship, beating the hosts 3-1 to join Mali in the quarter-finals.
Chistantus Ejike scored twice for Nigeria, either side of an Ifeanyi Ede penalty. Both sides had a man sent off.
In the other Group A match, Mali produced a 2-1 victory over Mozambique to ensure their place in the last eight as group winners , finishing one point above Nigeria.
Nigeria, who needed to win to progress, opened the scoring in the 21st minute when Ejike blasted a left footed shot from the edge of the six-yard-box into the top corner.
On 30 minutes, South Africa keeper Moeneeb Josephs conceded a penalty after spilling a routine free-kick. He got a hand to Ifeanyi Ede's effort from the spot, but was unable to stop Nigeria from pulling 2-0 ahead.
Ejike added a third in the second half for the Super Eagles, and almost made it a hatrick on 70 minutes, when his spectacular half volley from the edge of the box hit the crossbar.
With some 36,000 Bafana Bafana fans looking on, there was a glimmer of hope for the hosts on 74 minutes, when Nigerian defender Solomon Kwambe was sent off for a late tackle.
But the referee again reached for the red card two minutes later, sending off South Africa's Vuyo Mere for the same offence.
South Africa got a consolation on 81 minutes from the penalty spot, with Bernard Parker making it four goals from three group games.
Across the city at Athlone Stadium in Cape Town, Mali beat Mozambique 2-1 to win Group A.
Mozambique went into the match knowing they had no chance of progressing. Nevertheless, they took a surprise lead in the first half through Josemar to go into the break with the advantage.
Mali fought back quickly in the second half, Ibourahima Sidibe beating a host of Mozambican defenders in the box to knock the ball in from close range.
The match seemed destined to end in a 1-1 draw, but Mali made absolutely sure of their place in the last eight with a stoppage time penalty from Idrissa Traore to make it 2-1, ending as group A winners.