Mali beat Botswana to reach last eight
The Eagles, who finished on six points, one behind group leaders Ghana, will now face coach Alain Giresse's former team, co-hosts Gabon, in the last eight in Libreville on Sunday.
Botswana coach Stanley Tshosane made four changes from the side defeated 6-1 by Guinea last time out, including relegating Dipsy Selolwane, scorer of the Zebras' first-ever Cup of Nations goal on his return on Saturday, to the bench. Giresse was missing Samba Diakite, the suspended Nancy midfielder.
After a cagey opening Botswana created the first decent opportunity when Lemponye Tshireletso raced on to Ndiyapo Letsholathebe's neat flick in the box in the 20th minute only for his shot to go the wrong side of the near post.
Mali were having trouble breaking down the Zebras' defence, but with Ghana having taken the lead in Franceville Giresse's men only required a draw to go through as group runners-up. And even when news came through that Guinea had levelled and their legion of fans were still smiling as they remained in the runners-up spot, Botswana dampened their spirits six minutes after the restart in a beautifully worked move.
Mogakolodi Ngele found Moemedi Moatlaping over on the far right with a slide rule pass. Moemedi then controlled the ball well, handily positioned in the box, to slam past Mali goalkeeper Oumar Sissoko.
That sparked Mali into life and on 56 minutes they equalised when Abdou Traore's floating cross from the left was headed into the hands of goalkeeper Modiri Marumo by Modibo Maiga, with Dembele pouncing on the loose ball to convert a half-volley and send the Mali fans wild.
That was the 21-year-old striker's first goal for his country, and it couldn't have come at a more opportune moment. On 68 minutes Mali almost took the outright lead when substitute Ousmane Coulibaly struck the bottom side of the crossbar, the ball bouncing back into play.
They duly took it though with quarter of an hour remaining after sterling work fending off a posse of defenders in the box by Tidiane Cheick Diabete set up Keita to chip in from close range.
The Mali players had a nervous wait after the final whistle, an eery silence descending on the L'Amitie stadium with five minutes of stoppage time being played out in Franceville - all eyes transfixed on the giant screen where the Ghana game was being shown. When the agonising wait was finally over, and Mali's passage assured, the stadium erupted.