A brace from Ayoub El Kaabi and one from Walid El Karti was enough for host Morocco to see off a resilient Libya side 3-1 on Wednesday in Casablanca to book a place in the final.
El Kaabi, the leading marksman in the history of the tournament thanks to his six goals in the previous four games, headed Morocco in front 18 minutes from time following Zakaria Hadraf's quick counter perfect cross on the left.
But the host would be forced into extra time when Libya profited from goalkeeper Anas Zniti's error as he tried to dribble Saleh Taher with the ball rolling nicely for Abdulrahman Khalifa to fire home the equaliser four minutes from time.
El Kaabi restored Morocco's lead six minutes into extra time when Hadraf's inswing corner was flick by defender Jawad El Yamiq to the back post where the lanky forward unmarked tap-in the second and his eighth of the tournament to the delight of the home fans.
Playmaker El Karti won a late penalty from a heavy challenge in the by Mohamed Almaghasi and the Wydad forward made no mistake from the spot sending Mohamed Nashnush the wrong way and send his team to the final with Nigeria and Sudan facing each other in the second semi-final in Marrakech.
The host backed by their vocal supporters created the first opening four minutes into the game with a neat Salaheddine Saidi through ball setting El Karti through who chipped his effort over the onrushing Nashnush only for Sand Masaud to clear the goal bound effort.
Libya responded from a set piece as Mohamed Aleyat's delivery from the right into the Morocco box and Salem Ablo dived in to connect which failed to trouble Zniti who gathered with ease.
Fans favourite Bencharki found his club teammate Saidi with a nicely angled set piece midway the first half but the midfielder's towering header canoed off the wood work.
Defensive midfielder Badr Boulhroude and right full back Mohammed Nahiri all tried their luck from distance in the 31 and 39 minutes respectively, but in both occasions fired over the goal.
The host started the second half with more aggression in their attacks and El Karti glanced in a header straight at Nashnush on the hour mark from Hadraf's set piece.
Libya nearly silent the packed Complex Mohamed V when striker Taher headed in a corner but Abdeljalil Jbria was there to clear on the line.
Ismail El Haddad caused trouble on the on the flanks beating his marker on the right to deliver a cross towards the advancing Saidi who could not guide the ball past the keeper.
El Kaabi found a way past Nashnush with a pin point header from Zakaria Hadraf's cross to give his side a deserved lead on 73 minutes.
Omar Mohamed Elmaryami's side responded and scored with time running out courtesy Khalifa who punishing goalkeeper Zniti in his bid to dribble Taher and lost the ball to Khalifa who fired in the equaliser and forced extra time.
Libya beaming with confidence started the first half of extra time on a high Abdelsalam Alaqoub heading a corner towards goal which the Morocco defence cleared.
El Kaabi sent the home fans off their seats with a clinical finish from close when El Yamiq's header found him unmarked at the back post to restore Morocco's lead.
El Karti's late penalty made sure of victory after he won the spot kick following a heavy challenge in the area.
Total Man of the Match: Ayoub El Kaabi (Morocco)
Ayoub El Kaabi (Total Man of the match)
It was a difficult game against Libya who made it really tough for us, but we continued pushing for the goal which came in the second half.
They leveled but we still believed we could get the win in extra time which we did. I'm very pleased with the team's performance because they made it possible for me to score the goals.
We're now in the final so we will go back and prepare for that one because we want to win on Sunday.
Jamal Sellami (Head Coach, Morocco)
Congratulations to all Moroccans for the team's qualifications to the final. It was a good game despite the fact that we made some mistakes. In general, we played well and against a tough opponent.
I told my players to be calm and keep the ball which we did and found a way through. For us we want players who will come and add something to the game and with Zakaria Hadraf we had that.
As I always say, some players will start and others will join in when we need them in the second period. For the final we have not decided on who will start yet, but we will go and prepare well to win on Sunday.
Omar Mohamed Elmaryami (Head Coach, Libya)
I have to congratulate the brotherly nation of Morocco because Libya and Morocco have a lot in common not only football.
We tried to divide the match into parts and highjack it from Morocco but we were tired in the final phase which made it difficult for us.
Morocco played well and I have to congratulate them and not talk about decisions that did not go our way.
We will now focus on our match on Saturday for the third place and try to win it.