– The Trump administration on Monday lost a bid to persuade a federal court to allow long-term detention of migrant families, a significant legal setback to the president's immigration agenda.

In a ruling that countered nearly every argument posed by the Justice Department, Judge Dolly Gee of the Federal District Court in Los Angeles held that there was no basis to amend a long-standing court decision that forces the government to avoid holding migrant children for longer than 20 days.

Judge Gee said the administration's request was " a cynical attempt" to shift immigration policymaking to the courts.

President Donald Trump has pledged to end previous administrations' "catch-and-release" policy for illegal immigrants apprehended at the border, but the ruling left the administration with few good policy alternatives.

At the same time, federal immigration authorities were preparing to return 54 young migrants to their parents on Tuesday in a secretive operation that involves transporting children hundreds of miles to undisclosed locations around the country — reversing the government's earlier attempt to hold children and families separately.

The reunions, scheduled in order to comply with a federal court deadline, cover a little more than half of the youngest children — those under the age of 5 — who had been separated from their families under a Trump administration plan to slow the flood of migrants to the southwest border.

The operation will be carried out with an unusual level of secrecy under the oversight of the Department of Homeland Security, at locations operated by federal Immigration and Customs Enforcement, according to federal lawyers and others familiar with the plan.

A parallel effort is underway to deport some of the migrants: 11 reunified families will be returned to their home country, Guatemala, on Tuesday, the country's vice minister of foreign relations said at a news conference.

Most parents have already been transferred to detention facilities near where their children are held, Sarah Fabian, a Justice Department lawyer, said in court on Monday.

"The children will be brought to an ICE location where the parents are. ICE will assume custody and then release the parent and children together," she said. "We have agreed it is best to not talk publicly about location too much for the safety of children."

Judge Dana Sabraw of the Federal District Court in San Diego had set a deadline of Tuesday for the youngest children to be returned, but government lawyers said Monday that of 102 such children now in government custody, the authorities have been able to identify, locate and vet the parents of only 54. The court order requires all 3,000 children to be returned to their families before the end of the month.