Algeria will face Senegal in the final after a 95th minute free-kick by Riyad Mahrez settled a close semifinal. Their opponents beat Tunisia in the earlier semifinal, which was settled by an extra time own goal.
Algeria 2-1 Nigeria
(Troost-Ekong og 40', Mahrez 90'5 - Ighalo pen 72')
Riyad Mahrez rifled in a stoppage-time free-kick to earn Algeria a 2-1 victory over three-time champions Nigeria on Sunday and set up a rematch with Senegal in the Africa Cup of Nations final.
Algeria led through a first-half own goal by William Troost-Ekong before Nigeria equalised with an Odion Ighalo penalty awarded after a lengthy VAR review.
However, as extra time loomed, Mahrez blasted in from 20 yards with the last kick of the match to send the Desert Foxes through to their first final since lifting the trophy for the only time in 1990.
Algeria will take on Senegal for the title on July 19, in a repeat of a group stage clash they won 1-0.
Senegal 1-0 Tunisia
(Bronn og 100')
Senegal reached the final for the second time with a Dylan Bronn own goal giving them a 1-0 win over Tunisia in a tense last four clash in Cairo.
The key moment came in the 10th minute of extra time, goalkeeper Mouez Hassen pushed a free-kick against the head of Bronn and the ball went backwards into the net.
Tunisia thought they would have a chance to equalise when Idrissa Gueye handled in the box, but the Ethiopian referee inexplicably reversed his original decision to award a penalty after watching replays at the VAR monitor.
Both teams missed penalties in regular time with Ferjani Sassi the Tunisian culprit before Henri Saivet failed for the Senegalese.
Senegal will miss star defender Kalidou Koulibaly for the final against Algeria after he was yellow-carded. It was the second caution of the knockout phase for the Napoli centre-back and triggered an automatic one-match suspension.
Senegal last reached the title decider 17 years ago, when current coach Aliou Cisse captained a team beaten on penalties by Cameroon in Mali.