Mali reached the African Nations Cup quarter-finals for the first time since 2004 after coming from behind to beat Botswana 2-1 and finish second in Group D.
Botswana took a shock lead shortly after half-time through Mogakolodi Ngele, who timed his run perfectly to meet Moemedi Moatlhaping's cross and sidefoot firmly home for his first international goal.
However, Mali levelled six minutes later when Modiri Marumo parried Modibo Maiga's header but Garra Dembele emphatically hammered home the rebound from close range.
Barcelona midfielder Seydou Keita complete the Eagles' comeback, exchanging passes with substitute Cheick Diabate, just on for Dembele, before curling a measured first-time effort past Marumo with his left foot.
Ghana made certain of their progress into the quarter-finals as they held Guinea to a 1-1 draw, a result that sent their opponents out of the competition.
A screamer from Emmanuel Agyemang-Badu gave Ghana the lead in the 26th minute, and although Guinea levelled on the stroke of half-time through a fortuitous strike from Abdoul Camara, they could not find the goal they needed to go through.
Their challenge only made harder by the 70th minute dismissal of Mamadou Bah.
African Nations Cup quarter-final fixtures:
Zambia v Sudan - February 4
Ivory Coast v Equatorial Guinea - February 4
Gabon v Mali - February 5
Ghana v Tunisia - February 5