Following a goalless draw in their Group A opener against South Africa, Cape Verde impressed once more and Luis Platini went down in their history books with a landmark goal after 35 minutes.
They continued to boss the game, but a defensive lapse allowed Morocco to level in the 78th minute and they spent much of the final ten minutes on the backfoot as they fought to preserve a point.
There was a taste of things to come inside the opening minutes when Julio Tavares got on the end of a dangerous free-kick to force Nadir Lamyaghri into an early save. That was the cue for virtually one-way traffic throughout the opening 45 minutes, with Morocco mustering just two shots, neither of which troubled Josimar Vozinha.
Instead, Lamyaghri was the goalkeeper being kept busy as Tavares bullied the Morocco defence. He threatened again after winning possession 40 yards from goal and running through the defence, before pulling a shot just wide.
Ryan Mendes then brought a good save out of the goalkeeper with a low free-kick that looked to take the slightest deflection off the wall. Platini volleyed wide and then brought another good save from the goalkeeper as the pressure mounted.
The goal came in the 35th minute as Mendes split the defence with a through-ball and Platini raced on to chip it over Lamyaghri.
Cape Verde remained the better side in the second half, with Neves Nando heading over from Fernando Varela's cross while Tavares continued to make a nuisance of himself.
But just when it looked like Morocco had run out of ideas, they levelled 12 minutes from time. It looked all too easy from Cape Verde's point of view with Abdelaziz Barrada allowed room on the right to pull the ball back to the completely unmarked Youssef El Arabi to rifle home from the penalty spot.
Cape Verde almost responded moments later when Heldon ran on to a through-ball, but he did not make proper contact on his shot as the goalkeeper gathered.
But Morocco had found the spark they lacked, and El Arabi headed narrowly wide from a corner but Kamel Chafni sent a long-range effort desperately close after good work from Chahir Belghazouani won a corner.