Tunisia and South Africa filled the final two places in the Africa Cup of Nations last-16 draw Tuesday after a tense finish to the group stage in Egypt.
Already-qualified Mali defeated Angola 1-0 in Ismailia through an Amadou Haidara thunderbolt to win Group E and eliminate the losers from the competition.
Tunisia, ranked second in Africa behind Senegal, could only draw 0-0 with debutants Mauritania in Suez but the point secured second place behind Mali.
Mali won the group with seven points followed by Tunisia with three and Angola and Mauritania with two each.
Angola losing meant South Africa sneaked into the knockout phase, joining Guinea, the Democratic Republic of Congo and Benin as the best four third-place teams.
Mali will face the Ivory Coast in the round of 16 while Tunisia meet Ghana, who are chasing a seventh consecutive top-four finish in the Cup of Nations.
Highlight of the round is the clash of defending champions Cameroon and Nigeria, who have won the competition eight times between them.
Hosts Egypt, Algeria and Morocco, the three countries who finished first in groups with perfect three-win records, all face opponents who came third.
Mohamed Salah-inspired Egypt meet South Africa in a fixture sure to fill the 75,000-capacity Cairo International Stadium this Saturday.
Morocco face Benin in Cairo Friday in the first of the eight last-16 fixtures and Algeria tackle Guinea Sunday, also in the Egyptian capital.
Fairytale qualifiers Madagascar stay in Alexandria, where they stunned three-time former champions Nigeria to win Group B, for a showdown with DR Congo.
Boosted by a Sadio Mane brace against Kenya, Senegal will face another east African nation, Uganda, for a quarterfinals place.
In Ismailia, Mali made eight changes from the team that drew against Tunisia with captain Abdoulay Diaby and ace striker Moussa Marega among those on the bench.
Angola started with star winger Hermenegildo Geraldo after bringing him on as a second-half substitute in draws against Tunisia and Mauritania.
The countries were involved in the greatest Cup of Nations comeback with Mali wiping out a four-goal deficit on 77 minutes to draw 4-4 with 2010 hosts Angola in Luanda.
There was only one goal during the first half in Ismailia with Haidara putting the Malian Eagles ahead on 37 minutes.
After a patient build-up just outside the Angolan box, Haidara unleashed an unstoppable shot that flew wide of goalkeeper Tony Cabaca and into the corner of the net.
Mali should have been more than one goal ahead by half-time as unmarked Kalifa Coulibaly headed wide from close range.
Strangely lethargic during the opening half, Angola were more assertive after half-time and troubled the Mali defence regularly without making the crucial breakthrough.
After suffering a 4-1 hiding from Mali in their opening match, Mauritania kept a second successive clean sheet to contain Tunisia and bow out with heads held high.
Tunisia have been a major disappointment so far under French coach Alain Giresse, failing to win any of three group matches.