The first goal of the match came in the 40th minute of the first half when Nigerian defender William Troost-Ekong chested the ball into his own net in an effort to clear the ball from a free kick taken by the Algerian captain Riyad Mahrez.
Odion Ighalo got the equalizer for the Super Eagles when he converted the penalty awarded to his side when an Algerian player handled the ball within the 18-yard box after a VAR review to bring the score line to 1-1.
Mahrez handed the Algerian team the dramatic victory in the 95th minute when his free kick from outside the 18-yard box beat the Nigerian goalkeeper.
With this victory, Algeria will take on Senegal in the AFCON finals on Friday, July 19, while the Super Eagles will take on Tunisia for the 3rd place match on Wednesday, July 17.
In the first semi-final match played earlier on Sunday, Senegal defeated Tunisia by a lone goal to progress to the finals of the tournament.