Managers at the zoo in the capital of Rabat confirmed the details in a press statement.
The girl died a few hours after being transferred to hospital. Video shot by a zoo visitor shows a number of people huddled around the girl and holding her head, which was flowing with blood, while waiting for the ambulance to arrive.
The park management said the girl had been hit after the female elephant hurled the rock out of its enclosure. The girl had been in the visitors' area with her family, looking at the elephant and trying to take a picture.
The Rabat zoo does not use a metal fence to separate the animals from the visitors but has a huge ditch and wooden fence. Zoo managers sent their condolences to the girl's family and said in the statement that the zoo meets the required international safety standards.
This is the first incident of its kind since the zoo opened at the beginning of 2012. There are no previous records of animals at the zoo causing death or serious injury to visitors.
Rabat zoo is one of the largest in Morocco, home to many animals including some endangered species.