The apparent U-turn has led to questions over the migration policy of the new Socialist government of Spain, which has overtaken Italy to become the preferred destination of people wanting to get to Europe.
Criticised by the conservative opposition when it insisted on opening its doors, the recent expulsion has drawn stinging reproof from activists and sarcastic glee from the likes of Italy's far-right interior minister Matteo Salvini.
When Prime Minister Pedro Sanchez came to power on June 1 after ousting his conservative rival Mariano Rajoy, he scored a coup in Europe by opening up the eastern port of Valencia to the Aquarius.
The charity ship had made headlines after being refused entry in Italy and Malta despite having 630 migrants on board whom it had saved off the coast of Libya.
At the time, Sanchez's government had also announced it intended to facilitate healthcare access to illegal immigrants.
It also planned to remove barbed wire from the fences sealing off Ceuta and Melilla, another overseas Spanish territory in Morocco, which regularly tears through the hands and legs of migrants trying to scramble over.
But this had been strongly criticised by the conservative opposition who accused the Socialists of creating a “pull factor” for illegal immigration and encouraging human traffickers.
So far this year more than 32,000 migrants have arrived in Spain by sea and land, according to the International Organization for Migration — more than double arrivals for the same period in 2017.
After the Aquarius, another charity ship belonging to the NGO Open Arms was allowed to dock in Spanish ports three times.
But in mid-August, the Madrid decided to negotiate with other European states to divvy up migrants saved by the Aquarius, which was allowed to dock in Malta rather than Spain.
That was an early sign of change.
Then last week, Spain sent back to Morocco more than 100 migrants who had forced their way over the high double-fence of Ceuta in a mass expulsion condemned by human rights activists.
On Wednesday, two migrants suspected of being the ringleaders of another violent storming of the fence at the end of July were detained.
“We won't allow violent migration that attacks our country and our security forces,” Interior Minister Fernando Grande-Marlaska said Wednesday.
The apparent about-turn has drawn contempt from critics.
“The government is only right when it backs down,” Pablo Casado, head of the conservative Popular Party, said after the mass expulsion.
Activists, meanwhile, are fuming.
Helena Maleno, famed for her defence of migrants, slammed the measure on Monday as a “racist and colonialist policy”.
Deputy Prime Minister Carmen Calvo denied there had been any change, saying Spain's immigration policy followed two principles — “the respect of human rights and border security”.
Gemma Pinyol, a migration expert at consultancy Instrategies, said she believed the government “wanted to make an example and show they are taking decisions, so that people don't say it's a paradise of free entry”.
Even Europe's far-right movement waded in.
“Spain is showing us how to deal with illegal immigrants,” Alice Weidel of Germany's Alternative for Germany party, tweeted ironically.
Italy's Interior Minister Matteo Salvini (above) also responded with glee.
“If Spain does it, it's ok, but if I suggest it, I'm racist, fascist and inhuman,” he said on Twitter.
Politics expert Cristina Monge said this had discredited Sanchez.
“He had shown signs of having a more coherent policy, more ambitious, and this contradicts him so much that it's making him lose credibility,” she told AFP.
Pinyol believes people were too quick in thinking things would change radically from Mariano Rajoy's previous conservative government, which didn't honour its commitments where migration was concerned.
The Supreme Court even ordered the state in July to take in more refugees after ruling it had only welcomed less than 13 percent of the asylum seekers Rajoy had promised to accept in 2015.
“The change is in asking Europe to take on more responsibility,” said Pinyol.
But “if Spain says that and no one follows, it won't be of any use.”
She thinks Spain hasn't prepared well enough to take in migrants.
“The reception system should have been updated. The centres in Ceuta and Melilla are always saturated,” she said.