Morocco snatched a late 1-0 Africa Cup of Nations win after substitute Itamunua Keimuine undid Namibia's stout defensive efforts with a calamitous 89th-minute own goal.
Head coach Herve Renard is chasing a third triumph in the continental showpiece, having prevailed with the Ivory Coast in 2015 – three years after guiding an unfancied Zambia to glory.
But a Morocco side boasting plenty of technical ability and attacking talent struggled to break down a Namibia outfit ranked 113th in the world.
Dire Dawa City striker Keimuine was sent on to chase a famous win for his side but, having fouled Sofiane Boufal on the right flank, he inexplicably powered a header from the same player's free-kick into the turf and in.
Earlier in the contest, Namibia goalkeeper Lloyd Kazapua gathered a low drive from Ajax's Hakim Ziyech at the second attempt as Morocco failed to turn control of possession into regular clear chances before half-time.
Nordin Amrabat skipped away from Riaan Hanamub down the Namibia left early the second period, with Ryan Nyambe making a vital clearance as Youssef En-Nesyri sought to convert.
Boufal came on for central midfielder Mehdi Bourabia as Renard looked to force the issue.
Kazapua readjusted well to save with his boot from Ziyech – the playmaker's shot at the end of a 72nd-minute run having taken what looked like being a decisive deflection.
Boufal curled wide 12 minutes from time but Kazapua, having come through an apparent bout of cramp, was left with no chance when Keimuine erred horribly.