Morocco's government says it will close 1,256 mosques deemed unsafe to avoid a repeat of the collapse of a minaret in February that killed 41 people.
The ministry of religious affairs said more than 500 mosques would be completely demolished and rebuilt.
The ministry said makeshift rooms and tents would be provided for prayers.
King Mohammed ordered all the country's mosques to be examined after the centuries-old minaret of a mosque in Meknes fell over during Friday prayers.
The accident prompted widespread public criticism of the authorities over the apparent lack of maintenance of religious sites.
The religious affairs ministry said that after inspecting 19,205 of the country's nearly 48,000 mosques, it had been decided to completely close 6.5% and partially close 416, or 2.2%.
It said $325m had been set aside for the improvement works, including the demolition and rebuilding of 513 mosques.
The mosque in Meknes, whose historic city is on Unesco's World Heritage list, is among those being rebuilt.