Libreville - Mali secured their first Africa Cup of Nations quarter-final spot in eight years after a 2-1 win over Botswana here on Wednesday.
Goals from Garra Dembele and Barcelona star Seydou Keita put Mali into the all important Group D runners-up spot after the 1-1 draw between Ghana and Guinea in the other game being played simultaneously at Franceville.
The Eagles, who finished on six points, one behind group winners 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 routed 6-1 by Guinea last time out, including relegating Dipsy Selolwane, scorer of the Zebras' first ever Cup 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's attack was having trouble breaking down the Zebras' sky blue 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 the Mali team and their legion of fans were still smiling as they remained in the runners-up spot thanks to their 1-0 win over Guinea in their opening match.
Botswana dampened their spirits six minutes after the restart in a beautifully worked move with Mogakolodi Ngele finding Moemedi Moatlaping over on the far right.
Moemedi controlled the ball well with a slide rule pass for Ngele, now handily positioned in the box, to slam past Mali keeper Oumar Sissoko.
That sparked Mali into life and on 56 minutes they levelled when Abdou Traore's floating cross from the left was headed into the hands of keeper 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 Fribourg 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 underside 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 sky blue 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 over the stadium erupted.