Five of Spain's 17 autonomous regions - including Catalonia and Andalucia which provide more than one-third of national economic output and are not governed by the central government's ruling People's Party (PP) - said they would continue to treat immigrants who have no papers.
The ruling conservatives plan to end free treatment from the beginning of September as part of their austerity drive, aimed at cutting one of the eurozone's largest budget deficits and convincing nervous investors they can control Spain's finances.
Critics say the number of immigrants without papers is estimated at only about 150,000, so barring them from medical treatment would save very little and was pandering to prejudice.
"The new law is not ethical, it's not cost efficient, and it makes no sense for the public health system. It's based on myths that immigrants are abusing the system that are not true," said Alvaro Gonzalez, a specialist at a hospital in the northern region of Asturias who has led opposition to the measure.
The nearly 6 million documented immigrants in Spain, most of them legal residents, account for only 5% of the country's healthcare costs, according to a study by La Caixa bank published last year.
Some doctors in PP-ruled regions also reject a ban which they say is at odds with Spain's universal healthcare service and could end up costing the state more if immigrants go to hospital emergency rooms instead of seeing a regular doctor.
The Spanish Society for Family and Community Medicine, which initiated the campaign against the PP ban, says more than 1,400 doctors have signed up, including 22% of primary health providers from the PP-governed region of Madrid.
Regions not controlled by the PP have used the ban as a focus for their opposition to central government spending cuts.
Andalucia, ruled by the Socialist Party, hopes the government will change its stance by September, when public workers and labour unions plan protests against spending cuts.
"We are talking about people here, and a universal, free healthcare system that cannot change from one day to the next to stop treating these people," said María Jesús Montero, head of Andalucia's health department.
She said the region was committed to making cuts to reduce its deficit, but not in healthcare and education, which were 'red lines' the central government could not cross.