"UNHCR is concerned over a proposal by Spain to legalize automatic returns of people trying to cross border fences into its enclaves of Ceuta and Melilla," said the UN refugee agency's spokesman William Spindler.
Spindler told reporters that UNHCR understood the "complexity" of border management in the two enclaves, which are tucked into Morocco's Mediterranean coast.
But blanket, on the spot deportations could fall foul of the 1951 Refugee Convention, an international treaty protecting people who flee their homelands, he said.
"UNHCR stresses the importance of permitting access to territory to seek international protection," he said.
The two Spanish cities — which are the only land borders between the European Union and Africa — have since 2013 seen a sharp increase in numbers of illegal immigrants aiming to head into Europe itself.
The Spanish government last week announced that it would include a legal amendment in its planned new Citizen Security Law authorizing police to expel migrants who climb the fence around Melilla and Ceuta, without giving their asylum claims a hearing — a move slammed by opposition parties.
"When people reach Spanish territory, their right to ask for asylum had to be respected in the same way whether they come via Melilla or (Madrid's) Barajas airport," said Trinidad Jiménez, the foreign affairs spokesperson for Spain's largest opposition party, the socialist PSOE.
Meanwhile, the United Left (IU) party said the government "instead of getting rid of inhumane practices", was "announcing a reform that would legalize most of them".
Spindler said that around two thirds of those trying to cross the seven-metre (23-foot), triple-layer border fence were from countries torn by war, violence and persecution, including Syria, Central Africa Republic and Mali.
In 2013, around 4,200 people entered the enclaves illegally by land and sea, he said.
"So far this year, over 5,000 people have arrived, including 2,000 people fleeing the conflict in Syria, of whom 70 percent are women and children," he added.
Spindler also raised concerns about what he said was the growing use of violence at the border to deter migrants and asylum-seekers from trying to enter.
Earlier this month, a local human rights group, Prodein, filmed a video of Spanish officers beating a migrant as he hung on the fence and then carrying him apparently unconscious back to the Moroccan side.
"UNHCR calls upon the Spanish authorities to ensure that no violence is exercised at the Spanish borders and that they are managed with full respect for human rights and refugee law," said Spindler, echoing an earlier European Commission call.
The government denies that migrants who climb the fence should be considered as having reached Spanish territory.
Over recent months, crowds of migrants have sat perched for hours on the fence waiting for a chance to climb down and evade capture on the Spanish side.
In the latest attempts, hundreds tried unsuccessfully to storm the Melilla fence last week. Just one made it over into the area between the layers of fencing and was taken to hospital with a head wound, government officials said.