Just three of the migrants who charged towards the seven-metre (23-foot) fence in separate locations at dawn made it into the territory of Melilla, the Spanish government delegation there said in a statement.
Most of them were intercepted on the way by Moroccan security forces and a group of about 50 who got close to the fence were seen off by Spanish police backed by a helicopter.
The statement said there have now been more than 60 such attempts so far this year. In all, about 14,000 migrants have tried to make the crossing and some 2,000 have made into Melilla.
The Spanish government has called for more help from the European Union to guard the border at Melilla and another Spanish territory on the northern shore of Morocco, Ceuta. Together they have Europe's only land borders with Africa.
The government statement said no one was hurt in Wednesday's attempted crossing, but numerous migrants and police have been injured in other recent attempts.
Human rights groups such as Amnesty International complain Spain has been breaking the law by instantly deporting migrants who scramble over the fence into its north African territories.
One local rights group, Prodein, on October 15 filmed Spanish officers beating a migrant as he hung on the fence and then carrying him apparently unconscious back to the Moroccan side.
Spain's conservative government later said it would pass a legal amendment authorising police to expel migrants who climb over the fence, while ordering officers to take care to avoid injuries.
The United Nations High Commissioner for Refugees has warned that such expulsions may breach international law.
Spain's government blames human-trafficking gangs for bringing the migrants to the border and says the European Union has a duty to help it bear the heavy migratory pressure.