A federal judge in California has ruled that hundreds of illegal immigrant women and children in U.S. holding facilities should be released, another apparent setback for President Obama’s immigration policy, according to The Los Angeles Times.

U.S. District Judge Dolly Gee said Friday that the conditions in which the detainees are being held are “deplorable” and violate parts of an 18-year-old court settlement that put restrictions on the detention of migrant children.

The ruling also raises questions about what the administration will do with the estimated 1,700 parents and children at three detention facilities, two in Texas and one in Pennsylvania.

Last year, tens of thousands of women and unaccompanied minors from Central America arrived at the Southwest border, with many believing a rumor that unaccompanied children and single parents with at least one child would be allowed to stay.

More than 68,000 of them were apprehended and detained while officials decided whether they had a right to stay.

Many were being released and told to appear at immigration offices until the administration eventually opened new detention centers.

Gee said in her ruling that children in the two Texas facilities had been held in substandard conditions and gave the administration until Aug. 3 to respond.

“We are disappointed with the court's decision and are reviewing it in consultation with the Department of Justice,” Marsha Catron, press secretary for the U.S. Department of Homeland Security, said in a prepared statement given to The Times.

Many of the Central Americans who crossed the Southwest border illegally last summer said they were fleeing poverty and escalating gang violence.

The Texas facilities are run by private companies, while the one in Pennsylvania is run by a county government.

In February, a federal judge blocked Obama's 2012 executive action to protect millions of undocumented immigrants from being deported.

And a federal appeals court in New Orleans refused three months later to allow the program to go forward, denying an administration request to lift the lower court decision.

Gee’s decision is also seen as a victory for the immigrant rights lawyers who brought the case.

The ruling upholds a tentative decision Gee made in April and comes a week after the two sides told her that they failed to reach a new settlement agreement as she had requested.

The 1997 settlement bars immigrant children from being held in unlicensed, secure facilities. Gee found that settlement covered all children in the custody of federal immigration officials, even those being held with a parent.

The Justice Department had argued it was necessary to modify the settlement and use detention to try to deter more immigrants from coming to the border after last year's surge. The department also said it was an important way to keep families together while their immigration cases were being reviewed, but the judge rejected that argument in her decision.

The Associated Press contributed to this report.