Updated

California became a “sanctuary state” on Thursday as Democratic Gov. Jerry Brown signed legislation protecting illegal immigrants in defiance of the Trump administration.

The bill, approved by the state’s legislature last month, bars police from asking people about their immigration status or participating in federal immigration enforcement activities in most cases starting Jan. 1.

California is home to an estimated 2.3 million illegal immigrants.

In a written statement, Brown stressed that the law would not prohibit federal immigration officials from doing their jobs and would allow sheriffs to grant federal agents access to jails. But he said it prevents the “commandeering of local officials” to do immigration work.

“These are uncertain times for undocumented Californians and their families, and this bill strikes a balance that will protect public safety, while bringing a measure of comfort to those families who are now living in fear everyday,” Brown said.

Asked for comment, White House Press Secretary Sarah Sanders said she hopes California “will push back on their governor’s, I think, irresponsible decision moving forward.”

California’s Democratic Senate leader Kevin de Leon had introduced the bill in response to concerns in immigrant communities about President Trump’s tough campaign comments and statements on immigration.

But California’s influential sheriff’s association opposed the measure, warning it would make it harder for them to protect the public.

The legislation comes as the Trump administration has pledged to crack down on sanctuary cities that refuse to cooperate with federal immigration authorities.

“The bill risks the safety of good law enforcement officers and the safety of the neighborhoods that need their protection the most,” Attorney General Jeff Sessions said last month in Portland, Ore., urging Brown to reject the bill, according to The Los Angeles Times.

Meanwhile, members of federal immigration agencies have also voiced concern over the bill.

“By passing this bill, California politicians have chosen to prioritize politics over public safety,” Thomas Homan, the acting director of ICE, said in a statement last month. “Disturbingly, the legislation serves to codify a dangerous policy that deliberately obstructs our country’s immigration laws and shelters serious criminal alien offenders.”

The Associated Press contributed to this report.