Cairo - Riyad Mahrez rifled in a stoppage-time free-kick to earn Algeria a dramatic 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 VAR review.
However, as extra time looked necessary, 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 Sadio Mane's Senegal for the title on July 19, in a repeat of a group stage clash they won 1-0.
An injury to Youcef Atal, who fractured his collarbone during the quarter-final win over Ivory Coast on penalties, forced Djamel Belmadi to start Mehdi Zeffane at right-back, while Nigeria fielded the same team that overcame South Africa here.
Algeria supporters filled most of the lower tier at one end of the ground, dwarfing a small section of Nigeria fans, but there were large swathes of empty seats at the 75 000-capacity Cairo International Stadium.
Leading scorers in the tournament and considered the most impressive side, Algeria quickly asserted themselves as Ramy Bensebaini headed narrowly over before a wicked Youcef Belaili cross nearly lead to a goal for Baghdad Bounedjah.
Hesitant defending from Kenneth Omeruo just outside his own area then allowed Bounedjah to nip in, but the Al-Sadd striker could only shoot tamely at Daniel Akpeyi.
Seemingly having moved on from the penalty miss that reduced him to tears in the last round, Bounedjah was consistently proving a nuisance to a nervy Nigeria backline with Jamilu Collins relieved to see a toed clearance land on the roof of the net.
Nigeria countered intermittently as Ighalo dragged wide after Mahrez was caught in possession, but the Manchester City winger promptly atoned as Algeria made the breakthrough on 40 minutes.
After gathering the ball on the right Mahrez danced past Collins before sending over a cross that flicked off the left-back and struck a helpless Troost-Ekong in the midriff before tricking over the line.
Super Eagles boss Gernot Rohr has praised his side's resilience, particularly the way they bounced back from a shock loss to Madagascar to eliminate defending champions Cameroon, and Nigeria again hit back with the aid of VAR.
Gambian referee Bakary Gassama initially dismissed Nigerian penalty appeals when a Peter Etebo shot struck the arm of Aissa Mandi but reserved that decision, with Ighalo sending Rais Mbohli the wrong way from the spot for his competition-best fourth goal.
Sofiane Feghouli blazed over late on and extra time beckoned after Ismael Bennacer rattled the bar in stoppage time, but Mahrez won it at the death with a thunderous strike into the top corner.
Algerian commentator Hafid Derradji cries for Riyad Mahrez’ freekick that sent Algeria to the AFCON final. ???? pic.twitter.com/FrQYk3nyAc— Leandro Paredes (@Halopenos) July 14, 2019