It was the latest in a long series of attempts by desperate migrants trying to reach European soil via the territory on Morocco's northern shore.
The crowd of migrants charged to the six-metre (20-foot), triple-layer fence from encampments on the Moroccan side in the early morning, Spanish government delegates in Melilla said in a statement.
It accused the migrants of acting with "unusual violence".
Five Spanish police officers were treated for injuries and five migrants were hurt, most of them when falling from the fence.
"About 140 of the migrants ended up perched on the fence" where they remained for several hours before being seized by Moroccan security forces.
Three migrants made it to the Spanish side and went running into Melilla. Two of these headed straight to the city's immigrant reception centre and the third was yet be found, the statement said.
It said Spanish police planned to charge them with assault and resisting authority.
The injured Africans were due to be taken to the immigrant centre after receiving medical attention.
A group of about 100 migrants had also tried to scale the fence on Tuesday and five made it over, authorities said.
Thousands of migrants fleeing war and hardship try each year to cross the fences surrounding Melilla and Ceuta, two Spanish territories bordering Morocco which have the European Union's only land borders with Africa.
Others try to sail across the 15-kilometre (nine-mile) strait from Morocco to Spain in makeshift boats and inflatable dinghies, or to smuggle themselves into the country hidden in vehicles.
In early August, Spain's coast guard picked up over 1,000 people attempting to reach the country by boat.
Authorities blamed the rise in the number of migrants trying to cross the Strait on traffickers seeking to take advantage of calm summer seas and the end of the Islamic holy Ramadan month of fasting on July 28t
Lax policing in Morocco was also blamed with police sources telling Spain's El País newspaper Morocco's police and coast guard had not been on patrol for several days.