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).
by BBC Africa’s Matthew Kenyon:
“An average performance, but the most important [thing] is to win three points.” Morocco coach Herve Renard summed things up neatly – at the end of a game his team scarcely deserved to win.
It’s true the Atlas Lions had most of the possession – and their build-up play was effective at times. But in the final third, it broke down time and time again, to the obvious frustration of players and fans.
The last-minute own goal was so harsh on Namibia – who deserved a point, although they created little. Ivory Coast and South Africa have been warned. Morocco got away with this one, and will surely be keen to do better.