South Africa grabbed a late equaliser to draw 2-2 with Morocco on Sunday and take top spot in the final Group A table at the African Nations Cup.
Morocco, eliminated after drawing all three matches, were four minutes away from beating the hosts before defender Siyabonga Sangweni levelled.
Issam El Adoua opened the scoring for Morocco in the 10th minute at the Moses Mabhida Stadium.
Top of the group: South Africa's May Mahlangu celebrates his goal against Morocco
May Mahlangu pulled South Africa level with a curling shot in the 71st minute only for substitute Abdelilah Hafid to restore Morocco's lead with a breakaway goal 11 minutes later.
South Africa will stay in Durban for their quarter-final against the runners-up in Group B who will be determined on Monday.
Close: Morocco came within minutes of earning their first win of the competition
Massive underdogs Cape Verde Islands scored two late goals to snatch a dramatic 2-1 win over Angola and qualify for the quarter-finals of the African Nations Cup at the Nelson Mandela Bay Stadium on Sunday.
A header from Gege after 82 minutes and a strike from substitute Heldon in the first minute of stoppage time gave the islanders the most unlikely of wins and put them into the last eight after South Africa drew 2-2 with Morocco in the other Group A match in Durban.
Angola had taken the lead when Nando deflected the ball into his own net after 33 minutes, but even though Angola were winning for much of the match, they looked like being eliminated while Morocco were beating South Africa.
Pure delight: Cape Verde's Heldon celebrates his goal
Late goals in both games changed everything in the final minutes as Cape Verde clinched their place in the last eight to take second place in the group behind South Africa. Morocco finished third and Angola fourth.
The showdown in Port Elizabeth was the first time the two former Portuguese African colonies had met in the tournament and many of the players from both sides have links past and present at club level.
But despite the 'derby' aspect of the match, it got off to a ponderous start with lots of scrappy play from both sides.
Shock: Cape Verde's defender Fernando Varela celebrates after scoring against Angola
Back in the game: Angola get back on level terms
The end could hardly have been more different, ending in high drama as Cape Verde came from behind to win.
Angola coach Gustavo Ferrin made five changes to the side that lost 2-0 to South Africa in their previous match in a bid to give them a fighting chance of squeezing into the last eight.
Contrasting emotions: Cape Verde's coach Antunes flies the flag as Angola's coach Gustavo Ferrin looks angry
One of those changes, midfielder Djilma Campos helped set up their opening goal when he provided the cross for Mateus. Under pressure as Mateus went for goal, the ball took its deflection off Nando and went into the back of his own net.
But Cape Verde never stopped coming forward and equalised when Gege headed home after 82 minutes. The winner came when Lama made a dreadful mistake in the Angolan goal as Heldon swept home the winner.
More...
Read more: http://www.dailymail.co.uk/sport/football/article-2269147/Africa-Cup-Nations-Cape-Verde-2-Angola-1--Match-Report.html#ixzz2JExFs7hz
Follow us: @MailOnline on Twitter | DailyMail on Facebook