The stone got past the elephant's fence and a ditch separating the animal and visitors, the zoo said in a statement.
The girl was taken to hospital and died within a few hours, the zoo added.
The zoo statement said the enclosure met international standards and said "this kind of accident is rare, unpredictable and unusual".
Africa Live: More on this and other stories
The statement went on (in French) to point out two other recent incidents in the US:
Phyllis Lee, Scientific Director of the Amboseli Trust for Elephants, says that targeted throwing of stones and branches by elephants is very unusual.
"It can happen when elephants are frustrated or bored. In my opinion, it's unlikely the elephant was directly targeting the girl - but exhibiting frustration. You can't predict what animals in captivity will do."
The moments after the girl was struck at Rabat Zoo on Tuesday were filmed by a bystander and uploaded onto YouTube.
The video shows the elephant waving its trunk behind a fence and swerves round to show a stone on the ground.
Metres away people are gathered around the girl, holding her head and stroking her leg.
A seven-year-old girl has died after being hit by a stone thrown by an elephant from its enclosure at Rabat Zoo in Morocco.