After heated debate, the California Senate passed a so-called “sanctuary state” bill on Monday. While many Republicans argued that the bill would lead to dangerous criminals being let loose on the streets — warning that the measure would draw the ire of President Donald Trump — Democrats said that California had to take a stand in defense of “hardworking” immigrants that have become part of the country’s cultural and economic backbones.

The bill, formally known as Senate Bill 54, would prohibit state and local law enforcement agencies from using resources to investigate, detain, report or arrest persons for the purposes of immigration enforcement.

The Senate voted 27 to 12 along party lines to pass the measure, which will next be considered by the state Assembly before possibly going to the governor’s desk. California “cannot be intimidated” by threats from Trump to deny sanctuary jurisdictions of federal funds, said state Sen. Kevin de León, the bill’s author. “This is about making our communities safer, not less safe … We don’t grovel and put our hand out so we can get a little money and buy a police car,” he said. “Our role and responsibility is to protect all individuals.”

In an interview for a previous story, León told TIME that the bill will help ensure that all the state’s residents report violent crimes and feel safe enough to interact with government systems such as schools, hospitals and courts. Aggressive immigration enforcement policies have a “chilling effect,” he said.

“We don’t have to collaborate and use our local tax dollars to enforce federal immigration laws,” he said in that interview. “If they want to go after the bad guys, the violent felons and drug dealers, we are more than happy to continue to work with them. But if they want to split families up and deport the nanny, that’s not what America’s about and that’s not what California is about.”

Republicans argued on Monday that immigration policy is the domain of the federal government and the bill amounts to the state overstepping its bounds, saying that the measure would also make California a “magnet” for those who commit crimes.

Promising to deport undocumented immigrants was one of Trump’s key campaign promises. Since taking office, Trump has issued orders directing that immigration laws be enforced more aggressively and expanding the definition of “criminal aliens” who are targeted for deportation. Before taking office, Trump vowed to create a “deportation force” to carry out such work.

“You’ll be kicking the president right in the groin,” Republican state Sen. Jeff Stone said of the bill, “and I imagine he’s going to strike back.”

The ACLU’s Jennie Pasquarella, director of immigrants’ rights in California, told TIME that the bill is “critical because the only way for the federal government to carry out the kind of mass deportations that they are threatening is through cooperation with local law enforcement.”

While immigrant advocates and some law enforcement officials have expressed support for the measure, arguing that trust between immigrants and local officials is important for public safety, California sheriffs have said it could allow criminals to “slip through the cracks.” In advance of the vote, León amended his bill to allow local law enforcement agents to notify federal authorities about the release of violent criminals.

A new poll conducted by the University of California at Berkeley found that there is bipartisan support in the state when it comes to providing a pathway to citizenship and opposing Trump’s proposed wall on the U.S.-Mexico border, yet there are deep divides about sanctuary status. And those can grow deeper depending on how the notion of being a “sanctuary city” is described.

When asked whether they support cities declaring sanctuary status, meaning that local police and enforcement officials do not “automatically turn undocumented immigrants over to federal immigration officers,” 56% of California voters support that position – including 74% of Democrats but only 20% of Republicans.

When the Berkeley researchers framed the issue as an act of withholding – with sanctuary status meaning that cities can “ignore requests” to detain undocumented immigrants who have been arrested and are about to be released – those numbers essentially flip, with fewer Democrats supporting sanctuary status and even more Republicans opposed.

President Trump’s promises to crack down on illegal immigrants have caused fear and panic in many California communities. About 10 million immigrants live in California, and some estimates suggest that 25% of them may be undocumented. Churches have been lining up to offer sanctuary for immigrant residents, as some individuals have cowered in their homes, worried to answer the door for fear that immigration agents might be on the other side.

On March 27, U.S. Attorney General Jeff Sessions said the Department of Justice would be withholding grants from sanctuary cities and attempt to “claw back” any past grants. He cited crimes committed by undocumented immigrants, including the 2015 shooting of Kate Steinle in San Francisco. (Republicans brought up her name in the debate on Monday. “How many more Kate Steinle’s do we need?” said Sen. Stone.)

In late January, San Francisco became the first to sue the federal government over promises to starve sanctuary cities of federal funding, and California Attorney General Xavier Becerra filed a brief supporting that lawsuit following Sessions’ remarks. “Threatening to take away resources from sheriffs and police officers in order to promote misguided views on federal immigration policy is reckless and puts public safety at risk,” Becerra said in a statement.

California has emerged as one of the most powerful seats of resistance to conservative policies coming out of Washington since the election. Earlier in the day, lawmakers debated another measure that would help fund legal representation for immigrants in deportation proceedings, who can be left without counsel when they are unable to afford it.

While some Republicans lawmakers criticized the measure, saying taxpayers should not foot bills for immigrants who did not come through “the front door,” Democrats still found the votes to pass it in the Senate, 28 to 11, arguing that it was basic due process for a population that is crucial to the country.

“Immigrants are under attack,” said Democratic state Sen. Scott Wiener, expressing support for the bill. “It’s really important for California, for our government, for this legislature, to send a clear signal to our immigrant communities that we have your back.”

Get The Brief. Sign up to receive the top stories you need to know right now. Please enter a valid email address. Sign Up Now Check the box if you do not wish to receive promotional offers via email from TIME. You can unsubscribe at any time. By signing up you are agreeing to our Terms of Use and Privacy Policy . This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply. Thank you! For your security, we've sent a confirmation email to the address you entered. Click the link to confirm your subscription and begin receiving our newsletters. If you don't get the confirmation within 10 minutes, please check your spam folder.

Write to Katy Steinmetz at katy.steinmetz@time.com.