Zambia weathered a late rally to reach the quarter-finals for the first time in 14 years after securing top spot in Group D.
The Copper Bullets, who will face Nigeria in the last eight, finished in a three-way tie in the group but came out on top on goals scored. They were level on points and goal difference with Cameroon and Gabon but in a mini-league between the trio had scored four to Cameroon's three and Gabon's two.
Rainford Kalaba and a James Chamanga tap-in put Zambia 2-0 up before a goal seven minutes from time by Fabrice do Marcelino set up a tense finish. In the other match, Cameroon twice came from behind to confirm their last-eight place.
Sunday Angola v Ghana, Ivory Coast v Algeria
Monday Egypt v Cameroon, Zambia v Nigeria