The incident happened around 4:00 am (0300 GMT) near Benzu in the north of Ceuta with the migrants either scaling a barbed wire fence or swimming across to the Spanish city located on Africa's northern coast.
About 200 migrants tried to swim from Morocco into Ceuta, local authorities in northern Morocco told the state news agency MAP.
Moroccan authorities intercepted 104 would-be migrants and recovered two bodies in the waters near the border post, they added.
The would-be migrants threw stones and used sticks against police, the agency said.
Red Cross volunteers in Ceuta treated 185 migrants who managed to get into the territory for injuries of different degrees, the organisation said in a statement.
Twelve of them needed to be taken to hospital to treat injuries such as fractured bones, hypothermia or symptoms of drowning, it added.
Red Cross volunteers also gave clothes and shoes to the migrants before hey were taken to a temporary migrant detention centre in Ceuta.
Ceuta along with Melilla to the east are two Spanish territories on the northern coast of Morocco that together form the European Union's only land borders with Africa.
Spain fortified fences in the two territories last year in response to arise in the number of migrants trying to jump over the barriers from neighbouring Morocco.
Last year 15 migrants drowned in the Mediterranean after dozens tried to enter Ceuta by swimming from a nearby beach.
Human rights groups and migrants said the Spanish police tried to keep them from crossing into Spanish territory by firing rubber bullets and spraying them with tear gas.
The Spanish government has since said that its guards are now banned from using rubber bullets to repel migrants.