Spanish authorities carried out mass expulsions of migrants on Wednesday from its North African enclave of Ceuta after thousands crossed from Morocco, as the tide of humanity swimming around the border fence turned into a trickle.
Prime Minister Pedro Sanchez said as many as 4,800 of the more than 8,000 who entered Ceuta during the previous two days had been sent back, and security forces on both sides intervened to prevent more from crossing.
"We are carrying out the immediate handover of those who have entered irregularly," Sanchez told parliament.
On Wednesday morning, Spanish soldiers in combat gear and police officers were escorting some swimmers directly back to Morocco, while Moroccan police drove hundreds of young man away from the border fence.
The Spanish enclave's leader had earlier accused Moroccan authorities of failing to police their side of the border actively, and linked that to a decision by Madrid to admit a rebel leader from Western Sahara, a territory held by Morocco, to a Spanish hospital for treatment.
On Wednesday Morocco's minister of state for human rights, El Mustapha Ramid, suggested Rabat had a right to relax border controls over the hospitalisation of Polisario leader Brahim Ghali.
"What did Spain expect from Morocco, which sees its neighbour hosting the head of a group that took up arms against the kingdom?" he said in a Facebook post.
"Morocco has the right to lean back and stretch its legs... so that Spain knows that underestimating Morocco is costly," he added.
Sanchez did not make that connection, calling the north African nation a friend of Spain, while the interior ministry praised Morocco's cooperation over the migrant readmissions.
Foreign Minister Arancha Gonzalez Laya said on Wednesday morning in a radio interview that Spain has always been "exquisitely prudent" regarding Western Sahara.
She said Spain never intended to give Ghali's hospitalisation "an aggressive character".
Rabat recalled its ambassador to Madrid for consultations, said a diplomatic source who declined to be named, adding that relations with Spain needed a moment of "contemplation".
Moroccan authorities did not respond to requests for comment.
The crisis between the two countries is the most serious since a territorial spat over the islet of Perejil in 2002.