Riyad Mahrez scored a stunning free-kick with virtually the last kick of the game as Algeria beat Nigeria to reach the Africa Cup of Nations final.
With the tie heading for extra time, Manchester City forward Mahrez whipped a fierce set-piece into the top corner.
A William Troost-Ekong own goal had given Algeria the lead before Odion Ighalo’s penalty levelled the scores.
Algeria will face Senegal in the final on Friday.
Senegal reached the Africa Cup of Nations final for just the second time in their history having beaten Tunisia 1-0 after extra time in a dramatic match that saw both teams miss penalties.
The 2002 runners-up edged past Uganda and Benin with 1-0 victories in the previous two knockout rounds and maintained their impressive defensive record in Cairo as they eventually found a way past unfortunate Tunisia, who were denied another clear penalty late on.
Henri Saivet wasted a glorious chance to send Senegal through towards the end of normal time in Sunday’s clash when failing to convert from the penalty spot, five minutes after Ferjani Sassi had done likewise at the opposite end of the field.
An unfortunate own goal from Dylan Bronn 10 minutes into extra time proved to be the winner for Aliou Cisse’s side, who will face either Algeria or Nigeria in Friday’s final, but Tunisia felt aggrieved as they were awarded a late penalty only for that decision to be controversially overturned following a VAR check.
Senegal dominated the first half and should have taken a lead into the interval as Youssouf Sabaly hit the frame of the goal with his 18-yard curling attempt. Sadio Mane then fired wide when off balance after doing the hard work by rounding Mouez Hassen.
Taha Khenissi and Sassi came close for Tunisia in the space of a minute at the start of the second half, with the latter at least managing to test Alfred Gomis with his effort.
The game then exploded into life with 17 minutes of normal time to go as both teams were awarded a penalty.
Sassi’s shot was blocked by the arm of Kalidou Koulibaly in the box and the midfielder stepped up to take the poorly-taken pen, which Gomis was equal to down to his right.
Senegal were awarded a spot-kick of their own three minutes later after Bronn felled Ismaila Sarr in the box, but Saivet was next to be denied with his attempt towards the bottom-right corner of the net saved.
But Tunisia were unable to make the most of their reprieve as Hassen flapped at a cross, which hit Bronn on the hand and then the face before trickling over the line.
Yet another incredible twist saw the referee point to the penalty spot for a third time with 115 minutes on the clock after Salif Sane headed the ball against Idrissa Gueye’s arm, but the initial call was overruled after a VAR check to the anger of Tunisia’s players.