US District Judge Dana Sabraw says children five years old or younger must be reunified within 14 days from Tuesday.

A judge in the US state of California has ordered the Trump administration to direct border authorities to reunite within the next 30 days migrant children and their families separated at its southern border with Mexico.

If the children are younger than five years old, they must be reunified within 14 days of the order, the order issued late on Tuesday said

US District Judge Dana Sabraw in the city of San Diego issued the order following a lawsuit filed by the American Civil Liberties Union (ACLU).

The lawsuit involves a seven-year-old girl who was separated from her Congolese mother and a 14-year-old boy who was separated from his Brazilian mother.

Sabraw also issued a nationwide injunction on future family separations, unless the parent is deemed unfit.

She also criticised the Trump administration’s policy “a chaotic circumstance of the government’s own making”.

“The practice of separating these families was implemented without any effective system or procedure for tracking the children after they were separated from their parents,” Sabraw said.

“This is a startling reality.”

The ACLU also noted that the current crisis unfolding is “driven by the view that immigrants and asylum seekers deserve nothing but cruelty and punishment”.

More than 2,000 children have been separated from their parents in recent weeks and placed in government-contracted shelters.

Widespread outrage over the issue forced US President Donald Trump to issue an executive order to stop the separation of families, and said parents and children will instead be detained together.

In a separate development, 17 states, including California, Washington and New York are suing to force the Trump administration to reunite families who have been separated at the US-Mexico border.

The states, all led by Democratic attorneys general, joined Washington, DC, on Tuesday, in filing the lawsuit in the US District Court in Seattle, the first legal challenge by states over the practice.

In Texas, the chief executive of the nation’s largest shelters for migrant youths says he’s “ready now” to start reuniting hundreds of children with their parents.

Juan Sanchez of the non-profit Southwest Key Programs spoke to the Associated Press news agency just hours before the order of the California court.

Earlier, Health and Human Services Secretary Alex Azar refused to be pinned down on how long it would take.

He said his department does extensive vetting of parents to make sure they are not traffickers masquerading as parents.

Sanchez said he opposed the family-separation policy, but for the sake of the children, he felt his organisation needed to take them in.