|Pierre Aubameyang (L) scored the goal that ensured co-hosts finished top of their group [AFP]
Co-hosts Gabon defeated Tunisia 1-0 on Tuesday to finish top of Africa Cup of Nations Group C with a perfect nine points from three matches.
The Panthers will play the runners-up in Group D in Libreville on Sunday, while Tunisia, who finished second in the group will face the winners of Group D.
Pierre-Emerick Aubameyang gave Gabon the lead after 62 minutes when he collected a loose ball before wrong footing Tunisia goalkeeper Rami Jeridi for his third goal of the competition.
Skipper Daniel Cousin could have doubled the co-hosts' lead in the 67th minute but his shot from a rebound was well off target as Gabon seemed to be a revived team after the recess.
The north Africans fought to restore parity but the home team were resolute in defence to hold on for another famous victory.
"I don't have any preference who we play in the quarterfinals,'' said Gabon's coach Gernot Rohr.
"We're just happy to be there. We weren't expecting to be first (in the group) but we are first."
Meanwhile Morocco denied Niger their first ever point with a 1-0 win in their meaningless closing Group C tie.
With both teams already knocked out pride was the only prize on the table.
Niger, 45 minutes away from an historic first Nations cup point, held a prayer session before the restart.
They were looking at grabbing all three points as Karim Lancina's pinpoint 25m free-kick headed for goal on 46 minutes only for Mohamed Amsif to safely extinguish the danger.
Good work from Daouda Kassaly was keeping Morocco at bay until the 89th minute when Marouane Chamakh fed Montpellier midfielder Younes Belhanda whose sliding right-footed shot broke Niger's hearts and perhaps kept Morocco coach Eric Gerets in a job.