It was the latest in a wave of desperate bids by Africans to reach Europe that have left hundreds dead and police and migrants injured.
The crowd of "sub-Saharan migrants" rushed at the crossing from northern Morocco into the Spanish territory of Ceuta at dawn and "were stopped by the Moroccan security forces," a Spanish government official in Ceuta told AFP.
"They tried to rush across the border, but none managed to enter Spain," and the situation at the border soon returned to normal, he said.
He could not say whether anyone was injured, but said it "was one of the biggest groups in recent years" to make the attempt.
On September 17, some 350 migrants tried to reach Ceuta by swimming to one of its beaches from a nearby Moroccan shore and about 91 made it into the territory.
That same day in Melilla, the other of Spain's two territories on the northern Moroccan coast, 300 migrants tore down part of the border fence and 100 made it through, with scores of people injured.
Spain and Morocco deployed boosted security at the borders after those attempts.
Thousands of migrants fleeing poverty and unrest in Africa try to enter Europe each year, by land into Ceuta and Melilla and by sea to Spain or Italy, often in flimsy vessels.
A shipwreck off the Italian island of Lampedusa on October 3 left at least 359 migrants dead, according to media.