The parents of a woman who was fatally shot in San Francisco by an undocumented immigrant in 2015 cannot sue the city for freeing the man without telling federal immigration authorities just months before the shooting, a federal appeals court ruled this week. President Trump has highlighted the case in his attacks on illegal immigration and sanctuary cities.

Kathryn Steinle, 32, was shot by Jose Ines Garcia Zarate in July 2015 as she was walking on a San Francisco pier. Mr. Garcia Zarate, an undocumented immigrant who had been deported several times, had been freed by the San Francisco Sheriff’s Department less than three months earlier after charges against him were dropped in a separate drug case.

In a trial that lasted more than five weeks, Mr. Garcia Zarate was acquitted by a jury in November 2017 on murder and manslaughter charges but convicted of being a felon in possession of a firearm. He said he had fired the gun by accident, and evidence presented at the trial indicated the bullet had ricocheted.

Mr. Garcia Zarate was sentenced in January 2018 to the three years he had already served in prison pending trial. He faces two federal firearms charges in a separate case stemming from the July 2015 shooting. He has pleaded not guilty.