Surprise 2018 African Nations Championship (CHAN) star Ayoub el Kaabi scored twice as hosts Morocco overcame Libya 3-1 after extra time Wednesday in a Casablanca semi-final thriller.
Nigeria won the later semi-final 1-0 over Sudan in Marrakech with Okechukwu Gabriel scoring the only goal in a match where each side had a player red-carded.
Eight-goal El Kaabi is the runaway leading scorer in the tournament restricted to footballers playing in their country of birth, with his nearest rivals five behind.
He netted twice against Mauritania and scored a hat-trick against Guinea during the group stage before breaking the deadlock in a quarter-finals victory over Namibia.
The 24-year-old striker, who was not guaranteed a starting place ahead of the Championship, found space to nod Morocco in front after 73 minutes against dogged Libya.
But a moment of madness from goalkeeper Anis Zniti gifted Libya an equaliser four minutes from time to stun a near-capacity crowd at the 65,000-seat Stade Mohammed V.
The dribbling shot-stopper was dispossessed inside the box and Abdulrahman Khalifa struck the loose ball into the net past a miskicking defender.
El Kaabi put Morocco ahead again seven minutes into extra time with the easiest of his eight goals, tapping the ball into the net at the far post after Libya failed to clear a corner.
The sharpshooter from the Renaissance Berkane club in northeastern Morocco was then substituted by coach Jamal Sellami, who introduced a third centre-back to defend the slim advantage.
Morocco sealed a first final appearance in the five-edition tournament three minutes from time when fouled Walid el Karti converted the penalty.
The best previous showing by the Moroccans was reaching the 2014 quarter-finals, when they surrendered a three-goal lead to be beaten 4-3 by Nigeria in South Africa.
Nigerian Gabriel, who scored the extra-time winner against Angola in the quarter-finals, finished a route-one move by darting through to fire a low shot past Sudan captain Akram Elhadi.
The Nigerians were reduced to 10 men when Ifeanyi Ifeanyi was sent off for a studs-up tackle and Sudanese Bakri Bachir got his marching orders for shirt pulling.
It was the first loss suffered by Sudan in the biennial tournament since they debuted 2,551 days ago as 2011 hosts.
Although Europe-based professionals are ineligible for the Nations Championship, matches carry full international status and count toward the monthly FIFA rankings.