The debate has been fuelled by a series of riots and escape attempts in recent months at the seven centres.
The debate has been fuelled by a series of riots and escape attempts in recent months at the seven centres which are used to hold people caught living in Spain illegally while officials decide whether or not they will be deported.
The latest incident happened on Tuesday, when about 40 migrants tried in vain to flee a migrant detention centre in Barcelona during dinner time.
After their aborted escape attempt, some 70 migrants rioted at the centre before police were able to end their protest without violence, a local police spokesman said.
Last month 73 migrants escaped from a detention centre in the southeastern province of Murcia, in two separate incidents.
One of the most serious episodes happened at the centre in the southern Madrid district of Aluche on October 18, when dozens of migrants climbed onto the roof of the former prison where they spent the night and unfurled a banner reading "freedom".
After this incident some migrants at the centre suffered violence at the hands of police, according to anti-racism organisation SOS Racismo.
Last year, Europe saw an influx of more than one million migrants and asylum seekers fleeing war and poverty in its worst such crisis since World War II, and many countries have struggled to cope with the newcomers.
Rights group Amnesty International has accused Italian police of mistreating migrants, while France has come under fire over the closure last week of the notorious "Jungle" encampment housing thousands near the northern French port of Calais.
The crisis has fuelled anti-migrant parties across Europe, though not in Spain, where public opinion towards the new arrivals remains largely positive
Spain's two largest cities Madrid and Barcelona, which have been governed since June 2015 by citizens' platforms backed by far-left party Podemos, both want their migrant centres to be closed.
"It makes no sense to deprive of their liberty people who have not committed a crime and are waiting to be deported," said Madrid mayor Manuela Carmena, a former judge, on Wednesday after visiting the Aluche centre.
Critics claim that the steep public spending cuts imposed by Prime Minister Mariano Rajoy's conservative government have worsened conditions at the centres.
During a visit to the Madrid centre on Wednesday, Podemos lawmaker Ione Belarra said it was "in effect a jail" but with greater obscurity regarding how it is run, a view shared by many rights groups.
Police union SUP says many centres are dilapidated and have insufficient staff.
"Certain centres are very old, with no comfort and (are) not prepared" to receive migrants, SUP spokesman Ramon Cosio told AFP.
Centres in the south of the country "flood when it rains to the point that the detainees must roll up their trousers to the knee," he said.
Police officers often provide clothes themselves to migrants who come to the centres with nothing after arriving in Spain by boat, he added.
Foreigners placed in the centres can only move around freely during certain hours and must remain in their rooms at night, according to SOS Racismo.
They can see family members but only in visiting rooms, just as in prisons. Before glass partitions separated the detainees from their visitors but courts ordered they should be removed.
Critics accuse the government of keeping the migrants at the centres -- dubbed CIEs in Spanish -- in an ambiguous situation, in overcrowded rooms where police violence is rife.
"The CIEs are centres of pain and police impunity," the judge in charge of overseeing the Madrid's migrant centre, Ramiro Garcia de Dios, said in an interview published in online daily eldiario.es.
But Rafael Merino, a lawmaker with the ruling Popular Party, rejected the criticisms, saying during a visit to Madrid's CIE on Wednesday that there is "absolute respect for human rights" in the centres.
The number of migrants who passed through the centres plunged to below 7,000 last year from over 11,000 in 2012 due to more restrictive criteria regarding who needs to be held in them, according to the head of the Spanish police, Ignacio Cosido.
Only 41 percent of the migrants held in the centres last year were finally deported, according to the government's ombudsman.
Many end up in a grey zone, without permission to stay but still in the country, leaving them vulnerable to exploitation.
"They become cannon fodder for the job market and are in situation of semi-slavery," Podemos lawmaker Ione Belarra told AFP.