Mahrez showed class with his magically struck free kick on top of the box after Wilfred Ndidi committed an infringement.
Friday’s AFCON Final will thus be between Algeria and Senegal, while Nigeria will battle Tunisia in the losers’ final.
Africa News24 (AN24) reports that Algeria created the better chances in the first half and deserved their lead, but were pegged back in the second half by a spirited Nigerian team.
It was also Man of the Match Mahrez who was involved in the opening goal when his right cross was helped on by Nigeria defender William Ekong in the 40th minute.
Odion Ighalo drew Nigeria level in the 72ndminute from the penalty spot after VAR adjudged that Aissa Mandi handled the ball inside his box from a shot by Etebo.
It was his fourth goal of the tournament.
After several close calls in the seventh and 11th minutes, Ramy Bensibaini’s header off a free kick in the 16th minute did not miss the Nigerian goal by much.
Big striker Baghdad Bounedjah was a serious bother for the Nigeria defence.
In the 29th minute, he forced a point-blank save from goalkeeper Daniel Akpeyi after he sped past his marker Kenneth Omeruo.
In stoppage time of extra 4 minutes given, Algeria midfielder Ismael Bennacer saw his powerful shot from distance crash against the post with Akpeyi completely beaten.