Morocco's Interior Ministry reported that some 800 migrants had tried to storm the enclave, and that all had been arrested. It said 10 members of its security forces were seriously wounded.
"From now on those making such attempts will be presented before the competent judicial authorities who will decree their expulsion from the kingdom (of Morocco) or heavier penalties, according the gravity of the act," the ministry said in a statement.
Spain's two enclaves in Morocco, Ceuta and Melilla, are often used as entry points into Europe for African migrants, who either climb over their border fences or try to swim along the coast.
Spain has drawn criticism from human rights groups for allowing some migrants to be immediately turned back to Morocco in such incidents. They argue that skipping the lengthier deportation procedures deprives people of the opportunity to claim asylum.
In early December more than 400 sub-Saharan African migrants managed to force their way over the Ceuta border fence.
- Reuters, AAP