The collapse occurred as hundreds of people were gathering in Bab Berdieyinne mosque in Meknes, a town in northern Morocco located 140 km (87 miles) southeast of Rabat, it said.

"We were in the middle of prayers" when the structure collapsed, said one victim told Morocco TV from his hospital bed.

The incident occurred after several days of unrelenting rain, the television station reported. It broadcast video showing dozens of people inside the mosque carrying survivors out of the damaged structure to waiting ambulances.

King Mohammed VI has ordered that the mosque be rebuilt as soon as possible and that its original architecture be preserved, it said.