Ghana was cruising to a goalless draw to at least console themselves with a point until Boufal, who plays for S.CO. Angers in France punished the Stars following a defensive blunder.
In the first half, no decent chances were created from both sides, except with Thomas Partey who effected a free-kick that nearly beat Yassine Bounou in the 32nd minute.
With both sides chasing for a goal, Morocco was handed a free-kick outside the penalty box it was dealt with Joseph Wollacot with five minutes remaining to end the first.
Seven minutes from the break, the Atlas Lions mounted pressure on Black Stars which nearly gave them the lead.
Joseph Paintsil took the Moroccans on a counter-attack but he had no support to break the deadlock.
He again had a decent opportunity to hand Ghana a goal but his shot went wide.
The win puts Morocco on top of Group C with three points.
Ghana’s lineup: Joseph Luke Wollacot, Andrew Kyere-Yiadom, Thomas Partey, Jordan Piere Ayew, Andre Dede Ayew, Paintsil Joseph, Abdul Baba Rahman, Daniel Amartey, Iddrisu Baba Mohammed, Kamal Deen Sulemana, Alexander Djiku.