Mali reached the Africa Cup of Nations quarter-finals after beating Botswana 2-1 in Libreville.
Botswana took the lead through Mogakolodi Ngele's powerful finish past Mali goalkeeper Oumar Sissoko.
Garra Dembele then pounced on a rebound to equalise for Mali, before midfielder Seydou Keita hit the winner with a chipped finish, after a clever one-two.
The win saw the Malians finish second in Group D ahead of Guinea, who were held to a 1-1 draw by Ghana.
It is the first time in eight years that Mali have reached the knock-out stages, since they finished in fourth place in Tunisia in 2004.
Ahead of the game, the Malians were only certain that they had a better head-to-head record over Guinea, but knew they had to win to give themselves the best chance of progressing.
Mali started brightly and had the vast majority of the possession but Botswana grew in confidence as the game went on.
The Malians were restricted to just one decent chance in the first-half, with Modibo Maiga heading over the bar from the edge of the six-yard box.
Botswana threatened to derail Mali's quarter-final quest six minutes after the interval, as Moemedi Moatlhaping sent a cross into the box which Ngele slammed home beautifully at close-range, after sprinting into the area.
The Zebras' lead lasted just four minutes, as Dembele provided relief for the Eagles, connecting on the half-volley to fire home, after Modibo Maiga's header rebounded off Botswana goalkeeper Modiri Marumo.
Botswana replied to the equaliser well, pushing forward in an attempt to secure their first Nations Cup win.
But with just 15 minutes remaining, a moment of brilliance by Keita put the Malians in sight of the last eight.
The Barcelona midfielder played a quick one-two combination with Cheick Tidiane Diabate, and sliced home with a curling shot into the corner of the net.
The scoreline would be enough to see them through, with Mali's head-to-head advantage over the Guineans.
The Malians, however, had to wait for confirmation, as they watched the conclusion of the game in Franceville.
At the final whistle there, Keita and his team-mates erupted in celebrations with their fans, with qualification assured.
They will seek, however, to step up their game against co-hosts Gabon in the quarter-finals at the same venue on Sunday, as they were not quite convincing against Botswana.
Mali coach Alain Giresse spoke of his delight at his team's achievement afterwards, while admitting being unable to watch the outcome of the other fixture on the big screen.
"I was full of anguish at the end of the game having to wait.
"There is always this uncertainty, so I preferred to go back to the changing room and wait patiently for the outcome," Giresse said.
"It was a huge lift for us to score and the win means everything. We have a chance now to go all the way," added Giresse who was the former coach of Gabon.
"Now we have a quarter-final against Gabon. There'll be a great atmosphere, great competitiveness. We'll go away and prepare for it."