كتب : Omar AbdelAziz
Substitute Adnane Tighadouini scored the all-important goal for hosts Morocco, who now have six points from two games.
In the other group game in Tangiers, Senegal edged out Nigeria 2-1 to revive their chances and level on three points with Algeria.
Group B leaders Egypt face Ivory Coast on Wednesday, while South Africa take on Gabon.
The top two teams reach the last four, with the finalists and third-placed team automatically qualifying for the London finals. The fourth-placed nation will still face an Asian team.