Issam Jemaa scored a 90th-minute winner to put former champion Tunisia on the brink of qualifying for the African Cup of Nations quarterfinals with a hard-fought 2-1 victory over tournament debutant Niger.

The substitute stepped inside two defenders and hammered a left-footed shot into the net to finally shake off Niger's challenge in the Group C game at Stade de l'Amitie.

Youssef Msakni's second goal in two games put Tunisia ahead in the fourth minute and apparently on course for a straightforward victory, but Ngounou Tonji equalized five minutes later.

Niger had the Tunisians rattled for the rest of the first half, hitting the post and missing a string of chances through center forward Moussa Maazou before a shaky Tunisia found its composure in the second.

A win for co-host Gabon over Morocco in the group's second game on Friday will send both Tunisia and Gabon through to the last eight, ensuring the Moroccans would be the latest high-profile team to fall away at a surprising African Cup finals.

Niger's rousing rally after falling behind to an early goal against one of the continent's top teams nearly kept alive its slim hopes of progressing at its first tournament.

Tunisia's nerves finally settled, however, with Jemaa's late strike.

Libreville again put on a party as Gaguie, the football-playing gorilla and tournament mascot, danced on the athletics track around the pitch with yellow-clad performers.

Msakni put the Tunisians in front with a weaving run and finish reminiscent of his goal in the opening win over Morocco, skipping away from defenders and slipping his shot neatly past Kassaly Daouda.

It suggested Tunisia would breeze past the group underdog. That wasn't the case.

The lead lasted five minutes before Niger scored its first goal at a major tournament, with Tonji's header greeted with joy on the bench by players and coach Harouna Doula.

Maazou challenged goalkeeper Aymen Mathlouthi in the air with the striker flapping at the ball with his hand, but there seemed to be no contact and Tonji followed up to head into an empty net. The goal stood, despite strong protests from the 'keeper and teammates.

Maazou, who was embroiled in a physical battle with Tunisia captain Karim Haggui throughout the half, had a great chance to complete a shock turnaround in the 18th but he shot wide after shrugging off a challenge from Haggui.

The powerful forward again powered away from Haggui in the 30th before pushing a right-footed shot past the far post.

Niger right winger Issoufou Boubacar's shot three minutes later struck the same post after a touch from Mathlouthi, with Tunisia completely rattled and hanging on.

Tunisia boss Sami Trabelsi looked on with arms crossed, and his team would have been relieved to reach halftime without further damage against the suddenly rampant debutants.

Niger's players, as has become their tradition at the tournament, knelt in a huddle to pray at the end of the first half and before kickoff in the second.

Jemaa was brought on at the break and the experienced forward appeared to settle Tunisia.

Daouda was off his line quickly in the 57th to scramble a through ball away with Jemaa closing in, and Msakni curled a shot just wide soon after.

In the 64th, defender Aymen Abdennour - who had taken over the marking duties of the troublesome Maazou - surged forward and sent a low shot from way out bobbling past Daouda and off the same post that Niger had struck.

Almost immediately, Niger booted upfield to Maazou, who forced his way past the last defender but couldn't beat Mathlouthi.

Tunisia's Ammar Jemal headed over with Daouda out of position and the goal gaping in the 89th. He sank to his knees and screamed at himself in frustration with the North Africans appearing to have slipped up.

But Jemaa latched onto a pass on the right of the penalty area in the dying minutes, coolly cut inside the scrambling Niger defenders and finished convincingly.


AP Sports Writer Gerald Imray reported from Franceville, Gabon.