Namibia forward Iitamunua Keimuine’s 89th-minute own goal gifted Morocco victory in their opening Africa Cup of Nations Group D match.
Keimuine misjudged Ajax winger Hakim Ziyech’s free-kick as the 2017 quarter-finalists won in Cairo.
Two-time winning coach Herve Renard’s side were limited to largely long-range attempts against a Namibia side making their first appearance since 2008.
Ivory Coast face South Africa in Group D’s other match on Monday (15:30 BST).
Despite a starting line-up featuring Ajax player of the season Ziyech, Morocco looked on course for a point against a side ranked 113 in the world – in what is considered the tournament’s toughest group.
Nabil Dirar forced Namibia goalkeeper Loydt Kazapua to tip a looping long-range shot over in an uneventful first half, while Nordin Amrabat went down under a challenge by Danzil Haoseb but saw his appeals for a penalty dismissed.
In search of a solution, French coach Renard – who previously triumphed with Zambia in 2012 and Ivory Coast in 2015 – introduced Celta Vigo forward Sofiane Boufal who made a marked difference to the Morocco attack.
The former Southampton man almost made an instant impact, forcing Kazapua to save low to his right, before firing narrowly wide with 10 minutes remaining.
Ziyech, expected to leave Ajax this summer, offered darting runs and trickery but Namibia remained well-organised before suffering a cruel blow as Keimuine’s error handed Morocco all three points.
Next, Morocco face Renard’s former side Ivory Coast on Friday (18:00 BST), while Namibia come up against South Africa later that day (21:00 BST). BBC Sports