A US judge ordered that migrant families separated at the border with Mexico under President Donald Trump's "zero tolerance" policy be reunited within 30 days.
For children under five, reunification must take place within two weeks of the order, issued Tuesday by US District Judge Dana Sabraw in San Diego.
Sabraw issued the ruling in response to a suit filed by the American Civil Liberties Union on behalf of 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.
The judge also issued an injunction against any more family separations.
US federal authorities have 10 days to allow parents to call their children if they are not already in touch with them.
Trump signed an executive order last week halting his government's practice of taking children away from parents who cross the border without papers, even to seek asylum. Many are fleeing violence in Central America.
But the order made no specific provisions for families already separated under the policy, which drew scorn as inhumane and even a form of child abuse in heated criticism in America and around the world.
More than 2,000 children taken from their families remain under the care of federal authorities.
The judge was scathing in his criticism of the Trump policy of taking kids away from their parents.
"The facts set forth before the court portray reactive governance - responses to address a chaotic circumstance of the government's own making," Sabraw wrote in the 24-page ruling.
"They belie measured and ordered governance, which is central to the concept of due process enshrined in our Constitution," the judge added.