Namibian Itamunua Keimuine headed an 89th-minute Hakim Ziyech free-kick into his own net to gift Morocco a 1-0 victory Sunday in the opening Africa Cup of Nations Group D match.
It was cruel blow for the minnows from southern Africa, who lived up to their Brave Warriors nickname by taming the much-vaunted Atlas Lions.
Relief was etched on the face of Morocco coach Herve Renard as the final whistle blew after an unconvincing start by one of the competition favourites.
Renard is the only coach to win the Cup of Nations with two countries, guiding outsiders Zambia and previous underachievers the Ivory Coast to success between 2012 and 2015.
"We battled because of the good organisation of Namibia, the heat, and the fact that we were playing our first match," said Frenchman Renard.
"The most important thing was to take three points and I hope Namibia will pose problems for the Ivory Coast and South Africa."
Namibia coach Ricardo Mannetti said: "I had to comfort my players, especially the player who scored the own goal.
"I am so proud of my boys for the way they executed our tactics. Sometimes the game plan may not be nice to watch, but I was up against very experienced coach, a very experienced team."
As the match kicked off in 36 degree celsius (97 fahrenheit) heat at the Al Salam Stadium, the bookmakers, the Fifa rankings and Cup of Nations history favoured Morocco.
Morocco are 10/1 joint fifth favourites with bookmakers to win the title, 43 years after the only time they lifted a trophy that symbolises African national team supremacy.
The Atlas Lions lie 66 places above the Brave Warriors in the FIFA world rankings and they triumphed 5-1 on the previous occasion they met, 11 years ago.
However, while Morocco enjoyed 60 percent possession during the opening 45 minutes in the sweltering Egyptian capital, they rarely troubled Namibia goalkeeper Lloyd Kazapua.
It was a defender, right-back Nabil Dirar, who came closest to ending the stalemate with a fiercely struck 11th-minute shot from long range that flew just over the crossbar.
This was one of six goal attempts by the north Africans during the first half, but only two were on target.
Mannetti had warned his Group D opponents before the tournament that "even small dogs bite" and his side were a calm, well-organised outfit in the first half.
The second half was a replica of the first with Morocco pressing continuously and Namibia defending with discipline and intelligence.
Renard introduced Sofiane Boufal, who played for Celta Vigo in La Liga last season on loan from Southampton, and Karim el Ahmadi in an effort to break the deadlock.
The French coach played his final card on 78 minutes, introducing Khalid Boutaib, a familiar figure to Egyptians as he plays for famed Cairo club Zamalek.
Then, with the first goalless draw of the 2019 tournament looming, Keimuine watched in horror as his attempted clearance flew into the net.
Ivory Coast face South Africa Monday at the same stadium in a Group D showdown of former Cup of Nations winners.