Morocco tried to justify its passive stance to border control at Spain’s small north African enclave Ceuta amid a row over Madrid’s admission to hospital of a Western Sahara independence leader.
Spanish troops were sent to the border after a record 8,000 migrants entered Ceuta from Morocco on Monday and Tuesday.
Ceuta’s President Juan Jesus Vivas accused Morocco of failing to do enough to prevent the influx, while Spain’s Prime Minister Pedro Sanchez said the crossings signified “an act of defiance”.
“The lack of border control by Morocco is not a show of disrespect for Spain, but rather for the European Union,” he told the Spanish Parliament.
El Mustapha Ramid, Morocco's Minister for Human Rights, appeared to justify the country's approach after Brahim Ghali, the ailing Western Sahara official, was admitted to a Spanish hospital, which angered Morocco.
"What did Spain expect from Morocco, which sees its neighbour hosting the head of a group that took up arms against the kingdom?" he wrote on Facebook.
"Morocco has the right to lean back and stretch its legs … so that Spain knows that underestimating Morocco is costly."
As many as 4,800 migrants were returned from Ceuta, with Moroccan security forces stepping in to prevent further crossings.
"We are carrying out the immediate handover of those who entered irregularly," Mr Sanchez said.
Senior European officials offered their support to Spain.
Margaritis Schinas, a vice president of the European Commission, said on Wednesday that the continent “won’t be intimidated by anyone”.
European Council President Charles Michel said “co-operation, trust and shared commitments should be the principles of a strong relation between the European Union and Morocco”.
The EU’s home affairs chief Ylva Johansson said the influx was worrying.
“The most important thing now is that Morocco continues to commit to prevent irregular departures, and that those who do not have the right to stay are orderly and effectively returned,” she told the European Parliament.
“Spanish borders are European borders. The European Union wants to build a relationship with Morocco based on trust and shared commitments. Migration is a key element.”