SACRAMENTO — California lawmakers on Thursday gave final approval to a bill that would place strict limits on the disclosure of a person’s immigration status in open court, continuing the sanctuary state’s rebellion against the Trump administration’s illegal immigration crackdown.

Protesters take over Sansome Street in front of the Immigration and Customs Enforcement office in San Francisco, Calif., Wednesday, Feb. 28, 2018, to respond to the 150 detentions in Northern California by ICE this past week. (Karl Mondon/Bay Area News Group)

Senate Bill 785 was introduced in response to news reports of ICE agents tracking down undocumented immigrants in courthouses across the country. It takes aim at a tactic that advocates say is keeping many immigrants from testifying in court, reporting crimes or simply showing up to pay a ticket.

“This is about protecting public safety,” said Assemblywoman Gonzalez Fletcher, D-San Diego, one of the bill’s authors, in a statement Thursday. “Our criminal-justice system can’t function if witnesses or victims are afraid to testify out of fear of being deported. You should be able to testify against a murderer or rapist without fearing that you or your loved ones will be thrown out of the country as a result.”

A spokesman with U.S. Immigration and Customs Enforcement said the agency doesn’t comment on pending legislation.

The bill, introduced last year by Sen. Scott Wiener, D-San Francisco, passed the Senate Thursday with a bipartisan vote of 31-6. Six of the 13 Senate Republicans voted for the proposal and one did not vote.

If signed by Gov. Jerry Brown, it will take effect immediately.

“Courts need to be safe zones, but with rhetoric coming out of Washington, D.C., that demonizes immigrants and threatens mass deportations, entering a courtroom is more daunting than ever. Public safety is suffering as a result,” wrote Wiener in an editorial for the Sacramento Bee Monday with San Francisco District Attorney George Gascón, who sponsored the measure.

State Sen. Scott Wiener, D-San Francisco, holds a Capitol news conference Thursday after the passage of Senate Bill 785, which would prevent the disclosure of a person’s immigration status in court unless a judge deems the information relevant to the case. If Gov. Jerry Brown signs the bill, it takes effect immediately. Katy Murphy / Bay Area News Group

Wiener’s office said some attorneys are revealing the immigration status of victims or witnesses who come forward to participate in court cases, even when it’s not relevant, creating a “chilling effect” that can prevent others from coming forward.

In one case, a San Francisco mother who testified in court against her daughter’s alleged abuser was questioned about her immigration status and whether she’d been motivated to testify against the defendant in order to secure a special type of visa granted to people who cooperate with law enforcement, according to Wiener and Gascón. A judge ruled the woman’s immigration status was irrelevant to the case and couldn’t be considered by the jury, but the jury was unable to reach a verdict. When prosecutors tried to retry the case, the victim’s mother declined to testify a second time, in part because of the fact that her immigration status had been discussed, they said.

In a 2017 letter to U.S. Attorney General and former Department of Homeland Security John Kelly, California Chief Justice Tani G. Cantil-Sakauye expressed concern over reports that ICE agents are “stalking undocumented immigrants in our courthouses to make arrests” and asked immigration officials to keep enforcement tactics out of state courts.

“Our courts are the main point of contact for millions of the most vulnerable Californians in times of anxiety, stress and crises in their lives,” she said.

“Enforcement policies that include stalking courthouses and arresting undocumented immigrants, the vast majority of whom pose no risk to public safety, are neither safe nor fair.”

Though they’d also be protected under the legislation, criminal defendants likely wouldn’t be affected, since a person’s immigration status isn’t typically a factor in criminal cases. “It’s usually excluded from testimony,” said San Jose State political scientist Garrick Percival, of a person’s legal status.

Immigration cases are handled separately, in federal court.

Immigration enforcement has been a cornerstone of President Donald Trump’s administration. Since he launched his campaign for president, Trump has invoked the killing of Kate Steinle by an undocumented immigrant with multiple criminal convictions and prior deportations as an example of a broken immigration system. A San Francisco jury found Jose Inez Garcia Zarate not guilty in a murder trial after his defense attorney showed the shooting was accidental. However, Trump and Attorney General Jeff Sessions have used the Steinle case to justify ongoing ICE crackdowns that have many illegal immigrants living in fear.

The only group on record opposing the bill was the California News Publishers Association, which argued it would hurt the public’s interest by making some proceedings secret, hindering reporting.

“By automatically moving all discussions of the immigration status of parties and witnesses to a judges’ chambers,” the association wrote in its letter of opposition, “SB 785 establishes a per se ban on the public’s right to attend this aspect of criminal and civil proceedings which the Supreme Court found to be unconstitutional.”

A directive from U.S. Immigration and Customs Enforcement released in January allows immigration agents to enter courthouses to arrest targeted convicted criminals but bars them from detaining anyone else who may be undocumented. Cantil-Sakauye said the policy is a step in the right direction, while some advocates said it still allows ICE to step into courthouses, possibly dissuading undocumented immigrants from showing up at all.

Percival said the debate brings up the issue of separation of powers and, “whether ICE agents coming into courts is an infringement on the judicial system’s ability to do its work.”

“This is a continuation of a real fight about the balance of power between the federal and state government,” he said. “Not only that, but also between the executive and judicial branches. There’s a lot still left to unfold.”

Tatiana Sanchez covers race, demographics and immigration for the Bay Area News Group. She got her start in journalism in the California desert, where she covered the marginalized immigrant communities of the eastern Coachella Valley. Before heading north, Sanchez spent a year as immigration reporter at the San Diego Union-Tribune, where she covered the region's multicultural communities, social justice topics and life on the U.S. -Mexico border. A Bay Area native, she received a master's in journalism from Columbia University. In 2017, Sanchez was part of a team of East Bay Times reporters awarded the Pulitzer Prize for breaking news coverage of the Ghost Ship fire in Oakland. She's based in San Jose.

Katy Murphy is based in Sacramento and covers state government for The Mercury News and East Bay Times, a beat she took on in January 2017. Before that, she was the news organization's higher education reporter, writing about UC, CSU, community colleges and private colleges. Long ago, she covered Oakland schools and other K-12 education issues.

WASHINGTON (AP) — Tensions between the White House and Pentagon have stretched to near a breaking point over President Donald Trump's threat to use military force against street protests triggered by George Floyd's death.