Some 8,000 people have reached Ceuta in two days, Spanish officials say.
They say the migrants - who include about 1,500 minors - either swam around the border fences that jut out into the sea or walked across at low tide.
Spain's Prime Minister, Pedro Sánchez has vowed to restore order. Spain says around half of the migrants have been sent back to Morocco.
By Tuesday evening, footage of the beach showed that nearly all migrants had been cleared.
Mr Sánchez travelled to Ceuta and Melilla to deal with the crisis, which exacerbated diplomatic tensions with Morocco.
Morocco withdrew its ambassador for consultations after Spain's foreign minister told the envoy of her "disgust" at what had happened.
Most of the migrants are said to be from Morocco. The Spanish troops have been deployed to the beach to help border police at Ceuta's main entry point - Tarajal, on the enclave's south side.
Dramatic scenes were captured offshore as families waded through the water and officers from Spain's Guardia Civil went into the sea to rescue young children.
Interior Minister Fernando Grande-Marlaska said 200 troops, plus 200 extra police were going to assist Ceuta's normal 1,100-strong border force. The enclave has some 80,000 residents.