Ghana sealed their place in the Africa Cup of Nations quarter-finals with a 1-1 draw against Guinea in Franceville.
Emmanuel Agyemang Badu put the Black Stars ahead, smashing a fierce volley in from the edge of the area.
Abdoul Razzagui Camara equalised right on half-time, with what looked like a cross from the left-wing sailing right into Ghana's goal.
Guinea chased a winner to no avail, but Mali's 2-1 win over Botswana saw the Malians through and Guinea go out.
The tournament's final pair of group games were finely poised at the beginning of the night, with Ghana, Guinea and Mali all in with a good shout of progressing from Group D.
And Guinea started the brighter in Franceville, putting the Black Stars under pressure, but unable to create any clear early chances.
The Guineans had the ball in the back of the net first, but Ibrahima Traore was adjudged just offside, after getting in behind the Ghana defence and nut-megging Adam Kwarasey in the Black Stars goal.
Almost immediately, Ghana responded with the opener and a major contender for goal of the tournament.
Badu calmly collected the ball on the right edge of the Guinea area, before flicking it up with his left and hammering it into the top corner with his right.
It was Ghana's first real clear-cut chance of the game, and they happily slotted back into their comfort zone in its wake, happy to soak up Guinea's pressure.
The Syli Nationale duly obliged, earning a series of corners that put Kwarasey under real pressure, but the Ghana goalkeeper showed much more composure than he did in Botswana's 2-0 win over Mali, punching several Guinean crosses away well.
Guinea then almost handed Ghana a second, after confusion between their defence and goalkeeper Naby Yattara allowed Asamoah Gyan to almost get in before the ball broke to Samuel Inkoom, who chipped just wide.
Ghana looked to be headed for the break in front, but Guinea got their equaliser and put themselves briefly back in contention, with a goal from nowhere, right on the half-time whistle.
Camara ran down the left channel and chipped into the box at pace, before watching it sail right over Kwarasey and nestle in the net to put the sides level at the interval.
Guinea's Mamadou Dioulde Bah earned a suspension just after the break with a second yellow card of the tournament, and it would get worse for the Stuttgart midfielder, as he earned a second of the match and was dismissed for a trip on Kwadwo Asamoah.
Guinea tried to press for a second, but Ghana closed the game out well, retaining possession, and taking advantage of the extra man after Bah's dismissal.
The Black Stars finally took the sting out of the game and added a 1-1 draw to their two previous wins in the group to send them through, while Mali's 2-1 victory over Botswana sealed Guinea's fate.
Ghana assistant coach Kwesi Appiah paid tribute to his side for getting the result they needed to advance.
"We didn't want to get into a situation of problems,'' Appiah said.
"It was just important that we qualified for the next stage.
"At the end of the day, the most important thing is making sure you qualify.''
Guinea coach Michel Dussuyer said his players had shown a good will to win, but criticised referee Daniel Bennett for decisions made during the match, including Bah's first yellow card.
"We all know that Ghana is a great team but it didn't need the help of the referee,'' Dussuyer said.
"I am very disappointed with the performance of the referee.''
Ghana will take on Tunisia in their quarter-final in Franceville on Sunday, with Mali meeting co-hosts Gabon in Libreville.