Federal judge rules children, parents separated at border must be reunited within 30 days A federal judge in California also set a 14-day deadline for kids under 5.

After weeks of public outcry, a federal judge in California has temporarily halted the separation of families at the U.S.-Mexico border and ordered that children taken from their parents must be reunited within 30 days.

U.S. District Judge Dana Sabraw late Tuesday said the Trump administration has for months indiscriminately "engaged in a widespread practice of separating migrant families," including those who entered the country legally seeking asylum. The government, Sabraw wrote, was not prepared for the influx of separated children and had no plan in place for reunification.

Sabraw, a George W. Bush appointee, also ordered that children younger than 5 years old must be reunited with parents within 14 days and that all parents must be allowed to speak to their children within 10 days if they've not already been in contact.

The court also prohibited, absent a waiver, the deportation of parents without their children, and it said that in the future children can only be separated from a parent if that parent poses a threat to the child. If a parent is released from Department of Homeland Security custody, the child must be released to them.

About 2,300 children had been separated from parents since May.

"The court has saved these families from a nightmare. This is a huge victory," Lee Gelernt, who argued the case and is the American Civil Liberties Union's deputy director of the Immigrants' Rights Project, told ABC News.

In a searing criticism of the handling of these separations, Sabraw called it a "startling reality" that the government was not tracking the children once they were separated and did not enable communication between parents and children, noting that the same courtesies allowed for the personal property of incarcerated individuals weren't extended to migrant children.

"The unfortunate reality is that under the present system migrant children are not accounted for with the same efficiency and accuracy as property," Sabraw wrote. "Certainly, that cannot satisfy the requirements of due process."

The preliminary injunction applies nationwide.

The injunction was deemed necessary, Sabraw wrote, because the president's recent immigration order focuses more on reunifying families only when they are deported and says "nothing about reunification during the intervening time between return from criminal proceedings to ICE detention or the time in ICE detention prior to actual removal, which can take months."

In response, the Department of Justice said in a statement, the "court decision makes it even more imperative that Congress finally act to give federal law enforcement the ability to simultaneously enforce the law and keep families together. Without this action by Congress, lawlessness at the border will continue, which will only lead to predictable results—more heroin and fentanyl pushed by Mexican cartels plaguing our communities, a surge in MS-13 gang members, and an increase in the number of human trafficking prosecutions.”

At least one Democrat has argued the Trump administration was using the children as "bargaining chips."

The judge also said the injunction was necessary because Donald Trump's order contained too many loopholes, such as allowing for family separation if there is a mere "concern" that keeping families together is detrimental to a child.

Echoing an earlier ruling, Sabraw wrote that the practice of family separation, if proven true, could be considered "brutal" and "offensive," an action that "shocks the conscience." Weighing the interests of the government against those of the migrant plaintiffs, Sabraw ruled that the migrants faced greater immediate harm in that "the separations at issue have been agonizing for the parents who have endured them" and have caused "irreparable injury" to the children.

"Extraordinary relief is requested," Sabraw wrote, "and is warranted under the circumstances."

Family integrity, Sabraw concluded, is a constitutional right.