They were the latest in a wave of thousands of impoverished migrants trying to reach Spain, with officials saying their numbers have swelled in recent years due to unrest in northern Africa.
Before dawn, about 300 migrants tore down part of the six-metre (20-foot) high fence around Melilla, a Spanish-governed territory bordering northern Morocco and about 100 made it through, Spanish government officials there said in a statement.
"The raiders managed to pull down completely the border fence and entered violently, throwing objects at the security forces who tried to repel the assault," the statement said.
In a separate incident, another 350 people, described as migrants from sub-Saharan Africa, tried to reach Spain's other north African territory, Ceuta, by swimming to one of its beaches from a nearby Moroccan shore.
Of those, 91 made it, authorities said. A spokesman for the local Spanish government delegation said it was "the biggest assault on Ceuta since 2007."
He estimated about 700 more migrants were waiting near the border in Morocco hoping to cross to Ceuta.
Authorities said those who got into Melilla and Ceuta would be housed in crowded immigrant reception centres.
Officials said the one in Melilla is filled close to double its capacity of 480 people and the one in Ceuta is currently holding 750 people when it was built for about 500.
The governor of Melilla, Abdelmalik El Barkani, told reporters later that 40 metres (44 yards) of fence were destroyed in Tuesday's attempt.
Six Spanish civil guards there were injured as well as one migrant who was taken to hospital, believed to have broken his leg when he fell from the fence, the statement added.
Each home to around 80,000 people, Melilla and Ceuta have the European Union's only two land borders with Africa.
El Barkani has said that fighting in northern Africa and a crackdown on migration to the Spanish Canary Islands in the Atlantic have driven greater numbers of migrants to Melilla and Ceuta.
Human rights groups say the migrants are brought to Morocco from other African countries by traffickers and camp in the wild waiting for a chance to cross.
Others try to reach Spanish soil by sailing across the Mediterranean in makeshift vessels. On Monday officials said one migrant was found dead and a dozen were missing after their boat capsized in the attempt.