WASHINGTON (Reuters) - The U.S. government said in a court filing on Friday that it has the right to detain children and parents caught crossing the U.S. border illegally for the duration of their immigration proceedings.

A 1997 court settlement known as the Flores agreement has generally been interpreted to require the Department of Homeland Security to release illegal immigrant children from custody after 20 days.

But Justice Department lawyers said in the filing in U.S. District Court in California on Friday that they now have no choice but to hold children for as long as it takes to resolve their immigration cases, because of a preliminary injunction issued on Tuesday in a separate immigration case.

That case, brought by the American Civil Liberties Union in San Diego, challenged the recent government policy of separating families in order to detain parents for as long as necessary under President Donald Trump’s “zero-tolerance” policy.

Since that policy was implemented in May, families have been routinely separated after apprehension. Some 2,000 separated children are currently under government care.

An executive order issued by Trump this month reversed the policy, and the subsequent injunction in San Diego ordered the government to immediately stop separating parents and children and said families must be reunited in 30 days or less.

To comply with the injunction, the government said Friday it “will not separate families but detain families together during the pendency of immigration proceedings.” Cases can sometimes take months or years to resolve.

Under previous administrations, parents and children were often released to pursue immigration claims at liberty in the United States. Trump has decried that so-called catch-and-release policy, and vowed to detain immigration violators.