Spain's Civil Guard said 602 of the migrants made it onto Spanish soil in a massive assault on high, razor-wire fences shortly after dawn.
Migrants cut holes in the fences and threw feces and quicklime, a skin irritant, at police officers trying to hold them back, the Civil Guard said in a statement.
They also threw stones at police vehicles, breaking windows.
The police statement said 16 migrants were taken to the hospital, while five of 15 police hurt were also hospitalized.
The Spanish Red Cross said in a tweet that 132 migrants were hurt in the mass charge.
Sub-Saharan Africans living illegally in Morocco try to get to Europe each year by climbing rows of 20-feet high fences surrounding Ceuta and Melilla, Spain's other North African enclave.
Those who make it across head for crowded, temporary migrant accommodation centers. They are eventually repatriated or let go.
Spain's Maritime Rescue Service said it picked up 332 people in the Mediterranean on Thursday — 232 on 19 boats in the Strait and 100 in two boats further east. On Wednesday, it rescued 424 people.
The International Organization for Migration says so far this year more than 22,700 migrants have arrived in Spain — three times more than in the same period last year.
Almost 20,000 of them arrived by sea, as good weather allowed more crossings on the short route across the Strait of Gibraltar and a recent crackdown by Libyan authorities had led migrants to choose other routes.