The migrants surged over the fence into the Spanish enclave of Melilla on the northern coast of Morocco, the local Spanish government delegation said in a statement.
“A group of 150 sub-Saharans carried out a massive assault on the border fence of Melilla at about 6am (Spanish time) this morning in the Yasinen area near the city airport,” the statement said.
Despite the joint efforts of Moroccan forces and Spanish Civil Guards and police, “a large group of immigrants, about 50, managed to enter our city,” it added.
Ten of the Africans were treated for light injuries suffered during the attempt, as were two Spanish Civil Guards who were attacked as they tried to stop the migrants.
Melilla, a Spanish city of 76,000 people fenced off from Morocco, is a common destination for African migrants seeking to reach European soil.
Along with Ceuta, another Spanish enclave to the west, it forms one of Africa's two land borders with the European Union, a haven for many Africans fleeing poverty.
Spanish media citing the delegation said that around 100 migrants had made an unsuccessful bid to storm the Melilla fence on Saturday morning.
Spain reinforced security at the metal border fence in August after a resurgence of crossing attempts, with hundreds of would-be immigrants waiting nearby for a chance to climb over.
Many migrants also try to cross to Spain by sea in flimsy boats and various groups have been found drowned in the attempt over recent years.