Nineteen states filed a federal lawsuit Monday opposing the Trump administration’s new regulations for indefinitely detaining immigrant families.

California Attorney General Xavier Becerra and Massachusetts Attorney General Maura Healey led the effort by arguing that prolonged detention would cause irreparable harm to children and the communities that accept them after release from federal custody.

“This new Trump rule callously puts at risk the safety and well-being of children,” Becerra said in a statement. “No child deserves to be left in conditions inappropriate and harmful for their age.”

Federal authorities anticipated legal challenges to the proposal, which could take effect in 60 days if a federal judge approves. Kevin McAleenan, acting secretary of Homeland Security, said Wednesday in announcing the rule that it is intended to keep families together while processing their asylum claims efficiently.

“No child should be a pawn in a scheme to manipulate our immigration system," he said.

The regulatory proposal deals with the 1997 agreement reached in a class-action lawsuit known as the Flores settlement. The agreement calls for undocumented children who arrived unaccompanied to be released as expeditiously as possible for the child’s welfare. It includes a 20-day cap on the detentions.

A 2015 court decision expanded the policy to cover families, which administration officials said encouraged families to cross the border illegally under the prospect of a short detention.

U.S. District Court Judge Dolly Gee, who oversees the Flores settlement, would have to approve of the proposed Trump administration regulation before it replaces the Flores settlement.

ICE officials maintain that their detention facilities for families meet high standards for providing shelter, food, recreation and education. ICE has three facilities that have a total of about 3,000 beds for families, including two in Texas – the Karnes County Residential Center in Karnes City and the South Texas Family Residential Center in Dilley – and the Family Residential Center in Berks County, Pennsylvania.

Migrant families averaged about 50 days in detention while awaiting decisions in their cases before the 20-day cap was applied to them a few years ago, McAleenan said.

But conditions at short-term detention facilities have been contentious as a record influx of migrants strained the system. Migrants and lawyers have complained about inadequate health care, food and water, as well as unsanitary and unsafe conditions.

Other states participating in the lawsuit are: Connecticut, Delaware, Illinois, Maine, Maryland, Michigan, Minnesota, Nevada, New Jersey, New Mexico, New York, Oregon, Pennsylvania, Rhode Island, Vermont, Virginia, Washington and the District of Columbia.

“With this rule, the Trump administration is paving the way for ICE to imprison innocent children for indefinite periods of time and is attempting to take away the ability of states to stop them,” Healey of Massachusetts said in a statement. “This most recent attack on immigrant children is cruel, immoral, and illegal and we’re suing to stop it.”

More about the Trump administration's migrant detention policies:

Trump administration announces plan that would let it detain undocumented children indefinitely

'A kennel for dogs': Lawmakers hammer acting DHS chief Kevin McAleenan over migrant detention facilities

Judge panel to Trump administration: Detained migrant kids need soap and toothpaste