Edmilson Aguilar Punay, a 15-year-old from Guatemala, says the detention center where he was held was so crowded, some people had to sleep standing. USA TODAY

McALLEN, Texas — A judge in California on Tuesday ordered U.S. border authorities to reunite separated families within 30 days, setting a hard deadline in a process that has so far yielded uncertainty about when children might again see their parents.

If children are younger than 5, they must be reunified within 14 days of the order issued Tuesday by U.S. District Judge Dana Sabraw in San Diego. Sabraw, an appointee of President George W. Bush, also issued a nationwide injunction on future family separations, unless the parent is deemed unfit or doesn’t want to be with the child. It also requires the government to provide phone contact between parents and their children within 10 days.

More than 2,000 children have been separated from their parents in recent weeks and placed in government-contracted shelters — hundreds of miles away, in some cases — under a now-abandoned policy toward families caught illegally entering the U.S.

Amid an international outcry, Trump last week issued an executive order to stop the separation of families and said parents and children will instead be detained together.

The lawsuit in San Diego involves 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.

Also Tuesday, 17 states, including New York and California, sued the Trump administration Tuesday to force it to reunite children and parents. The states, all led by Democratic attorneys general, joined Washington, D.C., in filing the lawsuit in federal court in Seattle, arguing that they are being forced to shoulder increased child welfare, education and social services costs.

“The administration’s practice of separating families is cruel, plain and simple,” New Jersey Attorney General Gurbir Grewal said in a statement. “Every day, it seems like the administration is issuing new, contradictory policies and relying on new, contradictory justifications. But we can’t forget: The lives of real people hang in the balance.”

More: The Wall: Explore 2,000 miles between U.S., Mexico

In a speech before the conservative Criminal Justice Legal Foundation in Los Angeles, U.S. Attorney General Jeff Sessions defended the administration for taking a hardline stand on illegal immigration and said the voters elected President Donald Trump to do just that.

“This is the Trump era,” he said. “We are enforcing our laws again. We know whose side we are on – so does this group – and we’re on the side…