Flowers and a candle lay on the ground following a vigil for Kathryn Steinle on Monday in San Francisco. (Beck Diefenbach/Associated Press)

FOR YEARS, San Francisco law enforcement agencies have refused to work with federal immigration authorities, insisting that cooperation would subvert their efforts to cultivate good relations with the city’s highly diverse immigrant communities. In practice, the city’s sanctuary policy, applied blindly, subverts common sense by allowing dangerous criminals a free pass.

The latest victim of this triumph of doctrine over public safety was Kathryn Steinle, a 32-year-old woman who died July 1, according to police, after being shot in the chest by an illegal immigrant who has been deported five times in the past two decades and has a criminal record in four states reaching back to 1991, including multiple drug convictions.

The accused immigrant, Juan Francisco Lopez-Sanchez, had served various prison terms before he was transferred to San Francisco in March on an outstanding arrest warrant. Three weeks later, he was released from the city jail after local prosecutors dropped a decade-old drug charge against him. Rather than notifiying U.S. Immigration and Customs Enforcement (ICE), which had requested a heads-up so it could deport Mr. Lopez-Sanchez, the jail put him on the street without a word.

Sheriff Ross Mirkarimi, who runs the jail, defended the release as consistent with the city’s long-standing sanctuary policy. In fact, the policy allows authorities to exercise some discretion, particularly in the case of convicted felons. But in practice, Mr. Mirkarimi and other San Francisco officials have treated ICE as the enemy, stiff-arming all attempts at dialogue, cooperation or plain courtesy. Had the sheriff’s office — which could easily have seen Mr. Lopez-Sanchez’s extensive rap sheet — simply made a phone call to notify ICE of his scheduled release, he could have been handed over and deported. And Ms. Steinle would be alive.

Ostensibly, the city prides itself on protecting undocumented immigrants who it thinks might be unjustly expelled if they are arrested for traffic infractions and other minor violations. In fact, the Obama administration has made clear that its priorities for deportation are serious criminals and recent illegal border-crossers — not law-abiding immigrants with long-standing ties to communities.

That is a reasonable approach, and localities around the country with sanctuary policies — there are some 300 of them, though few operate as unyieldingly as San Francisco — should take note. No convicted felon, let alone one with multiple narcotics convictions, deserves sanctuary in the United States.

That would seem a statement of common sense, but not, apparently, in California. Of roughly 200,000 detention requests issued by ICE to local law enforcement agencies nationwide since the beginning of last year, fewer than 10 percent were declined. Of those declined, more than 60 percent were in California.

Now, as a consequence of Ms. Steinle’s death, shaken California officials are starting to rethink their intransigence. San Francisco Mayor Edwin M. Lee, a Democrat and himself the son of immigrants, is calling for a review of the sanctuary policy, saying it “was never designed to harbor repeat serious offenders.”

What a disgrace that it took a tragedy to prompt that realization.