A U.S. judge has 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 U.S. District Judge Dana Sabraw in San Diego.
Sabraw made the sternly worded decision in response to a suit filed by the American Civil Liberties Union on behalf of a 7-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, which was part of a policy under which anyone crossing the border illegally is detained and referred for criminal prosecution.
U.S. federal authorities have 10 days to allow parents to call their children if they are not already in touch with them, the judge said.
Trump last week signed an executive order halting his government's practice of taking children away from parents who cross the border without papers, even to seek asylum. Many are destitute people fleeing gang violence and other turmoil in Central America.
It was a rare retreat for Trump, who has made fighting immigration -- both illegal and legal -- one of the most sacred mantras of his fiercely U.S.-centered policy agenda.
But the order made no specific provisions for families already separated under the policy, which sparked heated criticism in America and worldwide as inhumane and even a form of child abuse.
More than 2,000 children taken from their families remain under the care of federal authorities. Some are just toddlers, or even infants.
The ACLU argued that the administration has no real plan for reuniting families.
Every night small children "are crying themselves to sleep wondering if they will ever see their parents again," said ACLU lawyer Lee Gelernt.
Now, the policy of detaining parents who cross illegally with children has been suspended, with authorities saying that among other factors they do not have space for all the families coming over from Mexico.
Judge Sabraw was scathing in his criticism of the Trump policy of taking children 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.
The attorneys-general of 18 mainly Democratic states also filed a lawsuit Tuesday challenging the Trump family separation policy.
They argued that Trump's order halting the practice has so many caveats it is meaningless. It calls for money to be appropriated to reunite families but does not say how much or by when, and depends on a judge allowing indefinite detention of children, the officials wrote.
"Keeping children separated from their parents is inhumane, unconscionable and illegal -- and we're filing suit to stop it," wrote Attorney General Barbara Underwood of New York.
Some 200 protesters turned out in Los Angeles to protest a visit by U.S. Attorney General Jeff Sessions, one of the most visible faces of the Trump border control policy.
Around 20 were arrested after defying police orders to disperse.
Trump did score a big win on immigration Tuesday, however, as the U.S. Supreme Court upheld the latest version of his travel ban targeting people from some Muslim-majority countries.
By a 5-4 vote, the court's conservative majority said Trump was within his legal authority as president to issue such a ban.
Trump pounced on the decision as an endorsement of his authority to defend national security and "a tremendous success and victory for the American people."
Immigration has been among the thorniest issue in American politics for decades, with Congress repeatedly failing to pass comprehensive reforms.
The House of Representatives intends to vote Wednesday on a broad immigration bill that ends family separations, but passage is in doubt. Should the bill fail, it would be a dramatic embarrassment for Trump's party.
Hannah Hanmer, who was protesting with her baby in Los Angeles, said she was angry the government was trying "to remove human dignity from immigrants" arriving with children.
"I want to be one of the people who said no," the 26-year-old told AFP.