The nationwide injunction issued Tuesday by US District Judge Dana Sabraw in San Diego, California, also ordered that those who were separated be reunited within 30 days.
However, the ruling will not be the final word over the US immigration crisis. An appeal by the Trump administration is likely.
Sabraw, an appointee of former Republican President George W. Bush, rebuked the Trump administration.
“The facts set forth before the court, portray reactive governance responses to address a chaotic circumstance of the government’s own making,” he wrote. “They belie measured and ordered governance, which is central to the concept of due process enshrined in our Constitution.”
The judge’s preliminary injunction also requires the US government to reunite children under the age of five with their parents within 14 days, and let children talk with their parents within 10 days.
More than 2,300 migrant children were separated from their parents as a result of the administration’s “zero tolerance” policy that began in early May and sought to prosecute all adults crossing the border without authorization, including those traveling with children.
The family separations sparked widespread condemnation in the United States and abroad, including from within Trump’s own Republican Party.
Although Trump issued an executive order on June 20 to end the family separations, it contained “loopholes” and did little to fix the problem, according to the American Civil Liberties Union (ACLU), which brought the San Diego case.
Some 2,000 children remain separated.
The ACLU hailed Sabraw’s decision. “This victory will be bring relief to all the parents and children who thought they may never see each other again,” ACLU lawyer Lee Gelernt said in an email. “It is a complete victory.”
The ruling came several hours after 17 states and Washington, DC sued the Trump administration in federal court in Seattle, Washington, over the family separations, calling them “cruel” and motivated by “animus.”