This is an archived article and the information in the article may be outdated. Please look at the time stamp on the story to see when it was last updated.

A federal judge in San Diego largely upheld California’s law banning private prisons in a ruling late Thursday, acknowledging that the state has the authority to ensure the health and welfare of federal detainees within its borders.

Under the ruling, at least four immigration detention centers with the capacity to house about 5,000 people would be phased out over the coming years.

However, the ruling carved out an exception when it comes to privately operated facilities that house pretrial inmates charged with federal crimes who are in the custody of the U.S. Marshals Service. U.S. District Judge Janis Sammartino issued a preliminary injunction that prohibits the state from enforcing the ban, known as Assembly Bill 32, on those detention centers while litigation on the matter proceeds.

Immigrant advocates celebrated the ruling, calling it a “major rebuke” to both U.S. Immigration and Customs Enforcement and The GEO Group, the for-profit contractor that runs several detention centers in California.

Read the full story on LATimes.com.