San Francisco prosecutors had a problem. They’d charged a suspect in a beating, but the key witness refused to testify, putting the case in jeopardy.

Then came a break that prosecutors credited to good luck as well as the city’s pro-immigrant sanctuary laws — which restrict cooperation between local authorities and federal deportation agents and have come under increasing fire from the Trump administration.

When prosecutors went back to the scene of the 2016 crime, they found another witness. The man, though, was undocumented and hesitant to come forward to testify, until he was assured that his status would not be shared with federal officials, said District Attorney George Gascón.

The city’s sanctuary ordinance “helps us in many ways and gives us access to witnesses and victims we would never have otherwise,” said Gascón, who noted that the case ended with a conviction for assault with a deadly weapon. “It allows us to break down cycles of violence, especially domestic violence.”

Anecdotes like this one are central to the argument that San Francisco and cities across California are well-served by sanctuary laws, allowing all people — regardless of status — to fully engage with public services, including police, schools and health care, rather than live in the shadows.

But when the Trump administration sued California last week in a bid to overturn three state laws — measures that drew inspiration from San Francisco’s longtime ordinance — federal officials argued the opposite. They said sanctuary laws threaten lives, especially a state law passed last year requiring local jails to release many undocumented people rather than turning them over to federal agents.

The lawsuit may turn on interpretations of states’ rights. But the larger debate centers on whether sanctuary policies are good for the health and safety of everyone in a community.

San Francisco police Capt. David Lazar said the results are clear in the world of crime-fighting.

“It happens every day in San Francisco — someone who knows we’re a sanctuary city cooperates and helps us,” Lazar said. “As we speak, someone is at some police station reporting a crime that maybe otherwise they wouldn’t have been.”

The city’s health and education leaders also assert that sanctuary rules — which state that San Francisco agencies cannot “ask about immigration status on any application for city benefits, services, or opportunities” — have made the city better.

Lydia Leung, medical director at San Francisco General Hospital’s Family Heath Center, said doctors interact daily with undocumented patients — people who consistently share that they feel secure seeking care in the city because they know their visit will not trigger immigration consequences. Failing to treat a portion of the population for disease could endanger public health in general, Leung said.

“If we want to create a healthier society, it requires us to pay attention to the health of all,” she said. “As a public health system, there is not an upside to ignoring any segment of society, because illness does not discriminate.”

City school board member Matt Haney said the school district has gone to lengths to remind parents that the city is a sanctuary, sending home written materials and even making robocalls after Trump was elected.

“We can’t operate our school district if families are afraid to talk to us, share with us and partner with us,” he said. “This is essential.”

But the Trump administration, and people who advocate stronger immigration enforcement, say the danger of sanctuary laws was made clear by incidents like the July 2015 killing of Kate Steinle on San Francisco’s Pier 14.

Federal immigration officers had sought to take custody of the undocumented immigrant shooter, Jose Ines Garcia Zarate, who had a long record of deportations and minor crimes. But the San Francisco sheriff’s department released him before the shooting under the city’s sanctuary ordinance.

Federal officials also cite the case of Nery Israel Estrada Margos, a Sonoma County man accused of murdering his girlfriend last year after he was released from jail. Immigration and Customs Enforcement officials had requested that Estrada Margos be held, so they could pick him up. Sonoma County notified ICE less than an hour before the inmate was let go — too late, the federal agency said, to pick him up.

“We are simply asking California and other sanctuary jurisdictions to stop actively obstructing federal law enforcement,” Attorney General Jeff Sessions said in a speech in Sacramento last week.

Not all California officials believe that limiting cooperation with deportation makes their communities safe. Fresno County Sheriff Margaret Mims told Fox News last week that she welcomes the administration’s lawsuit against three state sanctuary laws.

“Because we cannot talk to ICE about certain people in our jails,” Mims said, “they are free to go out and recommit crimes. We’re creating additional victims.”

San Francisco put in place sanctuary policies in the 1980s while seeking to protect people who escaped El Salvador and Guatemala at a time when the U.S., which supported both governments, didn’t recognize most of the migrants as refugees.

Over the years, the laws have evolved and expanded. The San Francisco sheriff’s department can now turn over inmates wanted by ICE only in extremely limited circumstances. If a person with Garcia Zarate’s record before the Pier 14 shooting were in San Francisco jail today, and eligible for release, he would still be freed rather than turned over to immigration agents in the absence of a federal warrant.

ICE sent 99 requests for San Francisco to hold or turn over undocumented inmates in 2016, and 469 requests in 2017, city records show. Already in 2018, the city has received 212 such requests. None have been honored.

To counter claims that its ordinance threatens safety, San Francisco officials point to research on immigrants and crime.

Though the federal government does not track people’s citizenship status when assembling crime data, studies over the last few decades have concluded that there is either no correlation between immigration and crime, or a negative relationship — meaning that as a city’s immigrant population increases, violent crime and property crime tend to decrease.

John Sandweg, a director of ICE under the Obama administration in 2013, said he believes local and state authorities have a role to play in helping ICE remove some dangerous individuals from communities. But he also understands why police and prosecutors want to restrict cooperation and avoid a chilling effect on witnesses.

He noted that with the Trump administration maintaining that every undocumented immigrant is a priority for removal, attempts at compromise with sanctuary jurisdictions like San Francisco seem unimaginable. Instead, Sandweg said, ICE will conduct more enforcement operations like one that resulted in 232 arrests in Northern California two weeks ago.

And local officials will dig in — as Oakland Mayor Libby Schaaf did when she revealed the secret operation in a public warning.

“All of this makes our country a little less safe,” Sandweg said of the divide. “It’s unfortunate that this has to be so politicized.”