Spanish police on Sunday cleared the last migrant camp on a beach in its North African enclave of Ceuta, ahead of a visit by the king.
It sprang up after a mass influx of more than 70,000 people into the territory from neighbouring Morocco at the end of July.
The sudden influx, during which scores of people died, sparked alarm across the European Union and triggered a political crisis in Madrid.
While most people returned with a few days, thousands have remained in the territory and have been sleeping rough in the street or on beaches.
Police backed by soldiers arrived shortly after 8 on Sunday morning at El Trampolin where about 3,000 people were living.
They put migrants onto buses to be taken to reception centres for processing, but some people fled into the nearby hills to avoid them.
Then cleaning crews arrived to dismantled the makeshift tents and clean the beach and esplanade.
Spain has been criticised for its slowness in responding to the situation which has created tensions in the territory.
King Felipe VI and Queen Letizia are scheduled to visit Ceuta on Tuesday, followed by Melilla, in the first trip to the territories by a Spanish monarch since 2007.
Rabat claims sovereignty over Spain's two tiny North African enclaves which are wedged between Morocco and the Mediterranean Sea.
