The lanky forward broke the deadlock nine minutes before the break when he latched on to Walid El Karti's first time pass to beat the Loydt Kazapua in the Namibian goal.
Jamal Sellami's charges took control of proceedings knocking the ball around trying to open the Namibian defence. El Haddad was found free on the left channel finding Achraf Bencharki who could not hit the target after nine minutes.
Winger El Haddad was a threat in attack for the host as he played a one two with Man of the Match Salaheddine Saidi who played in full back Mohammed Nahiri outside the area but his effort went wide.
Kazapua produced brilliant save to deny captain Badr Benoun's glancing header on 15 minutes from El Haddad's corner. Badr Benoun's earial prowess was again at play on the half hour mark but he headed Bencharki's cross off target.
Anas Zniti was called to action on 35 minutes as Namibia who rarely caused problems going forward managed to go past the solid Morocco defence, Ilmbondi releasing a cracking effort which the keeper gathered.
El Kaabi sent the home crowd wild went he latched on to El Karti's pass to beat Kazapua and thighten his grid on the scoring chat with his sixth of the tournament.
Morocco returned from the break much determined to secure victory with El Kaabi heading the busy Nahiri's cross over the goal.
Salaheddine Saidi made sure of victory with a clinical glancing header past the helpless Kazapua from a corner ten minutes into the second half.
Wydad forward Bencharki found space in the area after Namibia failed to clear a corner beating a couple of challenges before firing over.
Nahiri smashed the Namibian cross bar from a set piece late on as Morocco advance to the semis.
Salaheddine Saidi (Total Man of the Match)
We dominated play and deserved to go through against a well structured team. Namibia is a good team that is good in the air but we were determined to progress.
It was not easy but our qualities was better today. We needed the fans and they came out to see us through.
Ricardo Giovanni Mannetti (Head Coach, Namibia)
Today it was clear that the qualities were different and my players could not match the Moroccan players.
I will not sit here and criticise the referee, yes I was not happy with some decisions but I think Morocco were better than us and deserved to go through.
We wanted to surprise them but we couldn't and they showed their dominance. I'm disappointed but satisfied because no Namibian fan or player should drop their heads.
We have exceeded expectations and over achieved in this tournament. Our league should continue playing and that will help us going forward.
Jamal Sellami (Head Coach, Morocco)
For us today's game differs from the previous ones because it was a game we have to win.
Today we faced difficulties against Namibia but we found solutions and scored goals during good moments.
We have more experienced players than Namibia so that was why I said in the pre-match press conference that we will win this game and go through to the semi finals.
I don't know why the goal was not validated for Namibia. I really don't know if there was a foul or offside but I think we were better and created sufficient chances to win.