SAN FRANCISCO — A federal agency has agreed to allow a ranger to testify at a trial over a fatal San Francisco shooting with the ranger’s gun that became a flashpoint in the national immigration debate, a judge in San Francisco said Friday.

The scope of the ranger’s testimony will be determined by the judge who presides over Juan Francisco Lopez Sanchez’s trial in the 2015 shooting of Kate Steinle, Judge Richard Loftus said. He said he would leave it up to a judge next week to set a date for Lopez-Sanchez’s trial.

Lopez-Sanchez was living in the country illegally when he shot and killed Steinle while she walked with her father on a San Francisco pier crowded with tourists. He has said the shooting was accidental and has pleaded not guilty to second-degree murder.

As a candidate for president, Donald Trump used the shooting to argue for tougher immigration policies.

The handgun used in the shooting had been reported stolen by Bureau of Land Management ranger John Woychowski from the backseat of his car a few days before Lopez-Sanchez, 54, said he found it wrapped in a T-shirt on the pier and it accidentally fired as he handled it.

Federal officials had previously resisted efforts to have Woychowski testify about his stolen gun, but Loftus said the parties reached an agreement to produce the ranger as a witness.

Francisco Ugarte, an attorney for Lopez-Sanchez, said Woychowski’s testimony was key to answering questions about the gun’s history and condition.

Max Szabo, a spokesman for the San Francisco district attorney’s office, said it remained to be seen whether the ranger’s testimony was relevant to the case.

Lopez-Sanchez had been convicted five times of illegally re-entering the United States when the San Francisco sheriff released him from jail after a minor marijuana charge was dismissed. Lopez-Sanchez was released despite a request from federal immigration officials to detain him for possible deportation.

Trump and others seized on Steinle’s death to push for policies including prohibiting cities like San Francisco from refusing to cooperate with federal authorities on deportation matters.