Television images showed some of the migrants with bloodied arms and legs, apparently caused by the razor wire that tops the border fences, cheering as they walked toward a temporary reception center. Most of them were young men.
"I love Spain!" shouted one. Some were draped in European Union and Spanish flags.
More than 3,800 migrants have crossed the Moroccan border into the Spanish enclaves of Ceuta and Melilla so far this year, according to the U.N. refugee agency UNHCR. The route accounted for 14 percent of the total 27,600 who arrived, mainly by sea, between January and July, a 130 percent increase on the previous year.
Five migrants were injured in the jump, and seven Spanish policemen suffered burns caused by a corrosive substance thrown by the migrants, the spokesman said.
During a recent visit to Spain, German Chancellor Angela Merkel and Spanish Prime Minister Pedro Sanchez agreed to increase dialogue with Morocco to handle migrant inflows to Spain, which is now the main destination for people seeking a better life in Europe.
EU leaders have failed to agree a long-term plan on where to house migrants since brokering a convoluted deal in June that appeared designed to appease divergent views rather than provide concrete solutions to the crisis.
Eight days ago, five European Union countries agreed to take in 141 migrants on board the Mediterranean rescue ship Aquarius, a move that ended a four-day standoff in which Spain, Tunisia and Malta refused the ship entry.
(Reporting by Andrés González; Editing by Isla Binnie and Raissa Kasolowsky)