The number of people who have tried to illegally cross the border that separates the Spanish territory of Melilla from Morocco has nearly doubled this year but most fail to make it over, the interior ministry said Monday.

About 3,000 migrants tried to scale the border fence that surrounds Melilla, an autonomous Spanish city that borders northern Morocco, between January 1 and September 17, compared to 1,610 during the same period last year, the ministry said in a statement.

But nearly four-fifths, 77.3 percent, were prevented from entering the territory by Spanish and Moroccan security forces, the ministry added.

Last week, hundreds of sub-Saharan African migrants tried to enter Melilla and Ceuta, Spain's other north African territory, in assaults on the border.

The most spectacular attempt took place on September 17 when about 300 migrants tore down part of the three rows of six-metre-high (20 foot-high) fencing that surrounds Melilla and about 150 made it through.

While some of the migrants climbed the fence, others threw objects at border guards who were trying to stop them, Spanish authorities said.

Six Spanish police officers and one immigrant were injured in that assault, the government said.

Police video images showed dozens of migrants scrambling over the fence and starting to run as soon as they hit Spanish soil.

Nine migrants were treated at a Melilla hospital for injuries suffered during the border assault, including one who fractured his leg when he fell from the fence.

In a separate incident on the same day, another 350 people, described by authorities as migrants from sub-Saharan Africa, tried to reach Ceuta by swimming to one of its beaches from a nearby Moroccan shore and 91 managed to get in.

Spain is one of the main entry points in Europe for clandestine migrants from Africa.

Human rights groups say the migrants are brought to Morocco from other African countries by traffickers and camp in the wild while waiting for a chance to cross into Ceuta and Melilla, which have the European Union's only land borders with Africa.

Others try to reach Spanish soil by sailing across the Mediterranean in makeshift vessels.

"We are facing, in the majority of cases, a real human drama, of people who for different reasons are forced to leave their homes, and too often fall into the hands of unscrupulous gangs," Interior Minister Jorge Fernandez Diaz said Monday.

The Syrian civil war, the conflicts in Mali and the unrest sparked in North African and Middle Eastern countries by the "Arab Spring" have added to migratory pressures on Spain, he added, during a meeting in parliament with Moroccan officials to discuss migration.