Zambia and Cameroon advanced to the African Nations Cup quarter-finals by the slimmest margin on Thursday after Group D ended in a dramatic three-way tie.
Zambia beat Gabon 2-1 in Benguela to take top spot while Cameroon twice came from behind to draw 2-2 with Tunisia in Lubango and finish second.
The results saw Zambia and Cameroon end on four points, along with Gabon who had been top of the standings before the last day of group matches at the tournament in Angola.
Zambia, who will face Nigeria in the last eight in Lubango on Monday, finished top by virtue of the number of goals scored against the other three teams.
They were level on points with Cameroon and Gabon and also tied on goal difference but in a mini-league between the trio had scored four goals to Cameroons three and Gabons two to advance according to tournament regulations.
Cameroon will return to Benguela to play holders Egypt in their quarter-final tie on Monday.
NERVY FINISH
Zambia staved off a late rally from Gabon, who scored seven minutes from time to set up the possibility of a late recovery after being thoroughly outplayed for most of the match.
Fabrice do Marcelino's strike ensured a nervy finish for Zambia but they held out to reach the quarter-finals for the first time in their last six tournament appearances.
Rainford Kalaba got their first, beating the onrushing Gabon goalkeeper to a finely threaded through ball in the 28th minute. The second in the 62nd was a simple tap-in for James Chamanga.
Cameroon substitute Achille Webo set up two goals as they snatched their ticket to a seventh successive quarter-final appearance.
Webo, who came on at halftime, provided Samuel Etoo and Landry Nguemo with perfect passes as Cameroon fought back.
Tunisia, eliminated after drawing their three games, had gone ahead inside the first minute through Amine Chermiti and were in front again in the 63rd when Cameroon defender Aurelien Chedjou put the ball into his own net.
The Indomitable Lions defence was caught snoozing when striker Chermiti connected with a Khaled Souissi cross to head home after 50 seconds.
But soon after halftime Webo found Etoo, who coolly slotted home to level the match in the 47th minute.
Centre back Chedjou, however, lobbed his own keeper in an attempt to clear a cross as Tunisia regained the lead.
One minute later, Nguemo equalised for Cameroon when he fired past Aymen Mathlouthi from another Webo pass.
Tunisia finished with 10 men after defender Ammar Jemel was sent off for a second bookable offence in the 88th.
African Nations Cup: Gabon stun Cameroon
Eto'o helps pull Cameroon back from the brink
African Nations Cup: Egypt in last eight
Nigeria advance, Egypt maintain perfect record
Cameroon, Nigeria qualify, Egypt to play again