More than 300 migrants entered Spanish territory in North Africa early on Friday when they forced their way through a gate in the fence that separates Morocco from the Ceuta enclave, police said.
Three Spanish Civil Guard agents and two migrants were taken to hospital for treatment after the clashes at the Tarajal area of the fence, a spokesman said.
At least 10 members of the Moroccan armed forces were also injured, he added.
More than 30 migrants were treated at a migrant centre for bone fractures and other injuries.
Some were injured trying to scale the 20ft fence, which is topped with barbed wire, said Clemen Nunez, director of Ceuta's Red Cross emergency response team.
According to the Civil Guard, a surveillance camera showed around 600 people approaching the fence at about 6am local time.
They used tools and clubs to break one of the gates.
In video filmed by Faro TV Ceuta, some of the migrants can be seen with blood on their faces and bruises but mostly celebrating their arrival in Spanish territory.
Some wrapped themselves with Spanish and European flags and shouted "Freedom!"
Hundreds of sub-Saharan African migrants living illegally in Morocco regularly attempt to enter Ceuta and Melilla, Spain's other North African enclave, in the hope of getting into Europe.
Most are fleeing poverty and violence.
On Friday, 55 were rejected, according to the Civil Guard, because those who are intercepted on the spot can be returned to Morocco.
Those who make it over the fences are usually taken to migrant centres and eventually repatriated or let go, many choosing to seek asylum or work informally in Spain or other European countries.
Ceuta is separated from the rest of Spain by the Strait of Gibraltar.
Before the latest arrival, the migrant centre for temporary stay in Ceuta was already struggling to cope with more than 600 people, more than 100 over its maximum capacity, and making use of military tents in nearby car parks.