They were, however, for the most part contained by Spanish police and Moroccan gendarmerie, Spanish media reported on Wednesday.
Two refugees, one on each side of the border, were reported injured as they attempted to jump over the six-meter-high fence.
The Spanish government's delegation in Ceuta said six of the 400 who stormed the border managed to make it into Spain.
Refugees frequently jump or cut through the fence surrounding Ceuta and Melilla, Spain's two enclaves in northern Africa.
They also attempt to reach the territories by swimming along the Moroccan coastline.