(In this June 5 story corrects date of Trump taking office to Jan. 2017, in paragraph two)

A child traveling with a caravan of migrants from Central America sits at a camp near the San Ysidro checkpoint, after U.S. border authorities allowed the first small group of women and children entry from Mexico overnight, in Tijuana, Mexico May 1, 2018. REUTERS/Edgard Garrido

GENEVA (Reuters) - The United Nations called on the United States on Tuesday to stop detaining irregular migrant families and separating children on its frontier with Mexico, saying this broke the law.

Several hundred children crossing the southern U.S. border have been held in custody since October 2017 following an executive order issued by President Donald Trump when he took office in January 2017, it said.

“The U.S. should immediately halt this practice of separating families and stop criminalizing what should at most be an administrative offense – that of irregular entry or stay in the U.S.,” U.N. human rights spokeswoman Ravina Shamdasani told a briefing in Geneva.

“Entering a country without the relevant papers should not be a criminal offense...so these people should not be detained,” she said, adding that some children were very young, including a one-year-old infant.

Poverty, as well as deepening violence from criminal gangs and drug traffickers has driven hundreds of thousands of Central Americans to try to cross the U.S. border illegally or seek asylum in the country.

The Trump administration will soon begin fingerprinting parents claiming custody of children who entered the United States illegally without an adult relative, officials said a week ago, prompting criticism that children may be abandoned by those who fear being identified and deported.

Shamdasani, asked about comments by senior U.S. officials that it was normal to remove children from parents in custody, said: “There is nothing normal about detaining children.

“Detention is never in the best interests of the child and always constitutes a child rights violation,” she said.

The United States - the only country in the world not to have ratified the U.N. Convention on the Rights of the Child - still has obligations as a signatory to that treaty and as a party that has ratified other rights treaties, Shamdasani said

“Our position is that preserving family unity is a fundamental tenet of refugee protection,” U.N. refugee agency spokesman William Spindler said.

Most crossing the U.S. southern border are from Guatemala, Honduras and El Salvador where there is rampant violence and persecution targeting children and youth, he said.

“The fact that you have people coming from countries experiencing violence and might be subject to persecution by gangs and other criminal violence, would certainly ... give them the right to receive international protection,” Spindler said.