Spain's Guardia Civil police acted on Tuesday after scores of African migrants landed in the past week on the bare, rocky surface of Isla de Tierra, Spanish sovereign territory about the size of two football pitches, which lies an easy swim off the beach.
Ten women and children were taken off the islet to the Spanish territory of Melilla. "The others were removed at dawn," a spokesman for the Guardia Civil said, adding the operation was carried out "jointly" by Spain and Morocco "without any incident."
"We removed (the migrants) from the island because it was dangerous for them to stay there," he added.
Since the uninhabited rock is Spanish, Madrid feared it could open a new doorway to migrants, many of them fleeing poverty and unrest, who are desperate to reach Europe.
A Spanish interior ministry spokesman said the Guardia Civil evicted the migrants when sea conditions had calmed, and that the operation was completed at 4.30 am (0230 GMT).
"Many of the immigrants did not want to go Morocco, but there was no need to use force nor any troubles," the spokesman said.
By early afternoon on Tuesday, there were no traces of the emergency intervention, according to an AFP photographer at the scene.
Beyond the last summer holiday-makers, just two Moroccan policemen were posted on the beach, while the low tide made the island reachable by foot.
Melilla and Ceuta are two tiny Spanish enclaves in Morocco, the only land frontier between Africa and Europe.
Rabat considers the territories, held by Spain since 1580 and 1496, to be "occupied". Madrid refuses any discussion on the subject, which regularly poisons relations between the two nations.
But bilateral cooperation, especially over the problem of immigration, is unavoidable, as the interior ministry spokesman acknowledged.
"The eviction was handled entirely by the Guardia Civil but obviously together with Morocco because the Guardia Civil handed the immigrants over to their Moroccan counterparts," he said.
"The object is not so much to have to act like this but to avoid more immigrants arriving on Spanish rocks," he said.
Photographs in the online editions of Spanish dailies El Pais and El Mundo showed Guardia Civil apparently ferrying the immigrants to land by dinghy.
Migrants, some in handcuffs, were shown in the hands of police as they waded the final few metres (yards) to the beach to waiting Moroccan security forces.
In Rabat, Moroccan authorities said two migrants had been lightly injured in the operation.
A Moroccan security official said some 70 sub-Saharan migrants had been sent back to Morocco and "taken charge of" by the security forces.
According to the official, the migrants had crossed into Morocco from Algeria and would be expelled.
The stakes are high for Spain and the European Union, with African migrants frequently trying to enter Ceuta and Melilla by force.
On Monday, the Moroccan authorities expelled some 200 sub-Saharans from the country, most of them in the northern towns of Tetouan and Nador, close to the two Spanish territories, in a swoop on illegal immigrants.
Spanish Foreign Minister Jose Manuel Garcia-Margallo said earlier on Monday that he was convinced the arrival of the migrants on the Spanish islet was coordinated by "mafia who traffic human beings".
"The joint response of the Spanish and Moroccan governments, and the European Union, is to say 'That's enough' to those who traffic human beings, endangering the lives of the most vulnerable like pregnant women and young children," the Spanish prefect in Melilla, Abdelmalik El Barkani, told Spanish public radio.
Senior Spanish and Moroccan officials are due to attend an interparliamentary forum in Rabat on Wednesday, with migration expected to top the agenda.