San Francisco (CNN) The shooting death of a San Francisco woman had already fueled a fresh round of fierce debate over U.S. immigration policies. Now a new detail in the investigation adds another dimension to the discussion.

The gun used in the killing of Kate Steinle belonged to a federal agent, a source with knowledge of the investigation said.

It wasn't immediately clear what federal agency the gun was tied to, how it ended up in the hands of the alleged shooter or whether the revelation about where the weapon came from would affect the case.

"It doesn't in terms of charging this defendant," CNN legal analyst Danny Cevallos said, "but it may mean that somebody else is going to be on the hook, and soon."

The undocumented immigrant who's accused in the killing earlier told CNN affiliate KGO-TV that he found the gun wrapped inside a T-shirt on the ground.

Juan Francisco Lopez-Sanchez, who has a felony record and has been deported to Mexico five times , pleaded not guilty Tuesday to murder and weapons charges. His bail was set at $5 million.

Flanked by several public defenders and a translator, he seemed to struggle to understand what was going on in court, answering the judge's questions about court dates by repeating that he was not guilty.

At Tuesday's arraignment hearing, a prosecutor described Lopez-Sanchez as a danger to the public as she asked the judge to set as high a bail as possible.

"People are concerned about public safety," Assistant District Attorney Diana Garcia said. "This was an act of random violence. And the defendant claimed to have found this gun shortly before just firing it at somebody at close range, shooting an innocent victim in the back."

Kate Steinle died last Wednesday after being shot while walking at a San Francisco pier.

Matt Gonzalez, a public defender representing Lopez-Sanchez, said it's very likely the shooting was accidental and stressed that his client was not a violent person.

"There was no motive whatsoever for this defendant to cause any harm to the deceased," he said. "He did not know her. There's no allegation that this was any kind of crime, such as a robbery attempt or anything like that."

The investigation into the shooting is ongoing. But already the controversial case has drawn the attention of politicians campaigning for the nation's top job, casting a spotlight on U.S. immigration laws and what role local authorities should play in enforcing them.

The key question: Did San Francisco policies set the stage for the shooting, putting a criminal on the street instead of into the hands of federal authorities who could have deported him again?

Suspect released by city authorities

JUST WATCHED 5-time deportee confesses to shooting woman on pier Replay More Videos ... MUST WATCH 5-time deportee confesses to shooting woman on pier 01:52

Lopez-Sanchez told KGO he repeatedly returned to the United States after he was deported because he could find work and make more money than in his native Mexico. He said he has worked on ranches in Arizona and helped stock stores in Portland, Oregon

Asked whether he came to San Francisco because there were more opportunities and because officials there would not deport him, he said yes.

gave contradictory answers to reporters about what had happened and how he felt. He appeared disoriented and it was not clear whether he understood the questions in parts of the interview, which was conducted in English and Spanish. Lopez-Sanchez

He said he could not recall details of the shooting because he'd taken sleeping medication, but repeated several times that the shooting had been an accident and that the weapon had gone off on its own.

In March, Lopez-Sanchez was turned over to San Francisco authorities and ultimately released after completing a federal prison sentence.

U.S. Immigration and Customs Enforcement said San Francisco wanted him on a drug warrant, so the agency handed him over with a request to let it know if he was to be released.

Despite that request, San Francisco authorities let him go in April after the drug charges were dropped.

Freya Horne, chief legal counsel to the San Francisco County sheriff, said city officials believe such requests violate Fourth Amendment rights against unreasonable searches and seizures.

San Francisco Sheriff Ross Mirkarimi said his department requires a warrant or court order to transfer custody to federal authorities.

Critics who say the city erred in releasing Lopez-Sanchez, he said, are "completely wrong."

"As sheriff, I adhere to the laws that govern our land. And San Francisco's not alone. In fact, well over 300 municipalities have similar laws like San Francisco," he said. "Because of what has not been reconciled on the federal level, local governments and state governments are devising new laws."

According to CNN affiliate KRON , San Francisco's policy on undocumented immigrants says that police "shall not detain an individual on the basis of a civil immigration detainer after that individual becomes eligible for release from custody."

What role did sanctuary policy play?

Critics of such policies say they allow dangerous criminals to remain living in the United States.

"This woman would be alive today if they did not have this stupid sanctuary law in that crazy city of San Francisco," CNN law enforcement analyst Harry Houck said.

JUST WATCHED Trump: No one wants to talk immigration Replay More Videos ... MUST WATCH Trump: No one wants to talk immigration 00:10

But Ana Maria Salazar, a former deputy secretary of state and policy adviser in the Clinton administration, said such policies don't make for more violence.

"All that data shows that migrants who have documents or who are undocumented who come to the United States have lower crime rates," she said. "You cannot say that it was this policy per se that resulted in the death of this woman."

In an interview with CNN on Tuesday , Democratic presidential hopeful Hillary Clinton said San Francisco should have listened to the Department of Homeland Security and made a mistake when it didn't send Lopez-Sanchez packing.

"I have absolutely no support for a city that ignores the strong evidence that should be acted on. ... If it were a first-time traffic citation, if it were something minor, a misdemeanor, that's entirely different," she said. "This man had already been deported five times. And he should have been deported at the request of the federal government."

In a statement Monday, California Attorney General Kamala Harris cautioned against using the case as a springboard for shaping immigration policy.

"A young, innocent woman, Kathryn Steinle, has been killed, and her murderer must be brought to justice. My office stands ready to support the prosecution to ensure he faces swift accountability and consequences," she said. "On the issue of immigration, our policy should not be informed by our collective outrage about one man's conduct."