Mali, out of contention after defeats in their previous two games, bowed out on a high note with victory thanks to a Ragab Abdelnabi own goal that saw them exit together with Egypt, who needed a win to keep alive their hopes.
Algeria and Nigeria finished on five points apiece, Mali on three and Egypt in that order with two points.
With their destiny in their hands, Hossam Al-Badri’s charges failed to live up to expectation when it mattered most.
Zamalek midfielder Mahmoud ‘Kahraba’ Abdelmonem shot into the waiting hands of Mali goalie Djigui Diarra in the opening minutes.
On 18 minutes, Mali shot into the lead after Abdelnabi inadvertently headed into his own net for the goal that will haunt the Pharaohs for the remainder of the game.
Just before the break, Ramadan Sobhy was unlucky to draw level with a shot that missed target narrowly.
The Egyptians resumed hungrier but Mali goalie Diarra stood between them and the equalizer with superb saves off Kahraba, Sobhy and Mohamed Abdelkhader. On 76 minutes, Kahraba put Sobhy through, but the teenager shot wide with only Diarra to beat.
At the other end, winger Adama Traore of TP Mazembe fame profited from a blunder by the Egyptian defence, intercepting a Mohamed Sharf Edin back-pass to goalkeeper Mossad Awad, but Rami Rabia weathered the situation with a timely clearance on the goal line.
Algeria, who finished winners of Group B will face South Africa at the semis whilst Nigeria battles host Senegal.
Algeria 0-0 Nigeria
Egypt 0-1 Mali