A judge declined Thursday to toss out the confession of a suspect charged with murder in a San Francisco shooting at the center of the national immigration debate.

Defense attorneys argued during a preliminary hearing that police didn't have good reason to arrest Juan Francisco Lopez-Sanchez an hour after the shooting of a young woman on a pier in San Francisco.

The attorneys argued that no one saw Lopez-Sanchez, who is in the country illegally, fire the gun on July 1 and that police arrested him because he was a homeless person acting suspiciously.

Several witnesses took photos of Lopez-Sanchez walking briskly away from 32-year-old victim Kate Steinle. Police used the photos to arrest Lopez-Sanchez, who then told investigators he accidentally shot Steinle.

Judge Brendan Conroy ruled Thursday that police acted appropriately in arresting and interrogating the suspect. The judge said he will rule Friday on whether the suspect must stand trial for murder.

The shooting triggered a national debate over immigration after it was revealed that the San Francisco Sheriff's Department had released Lopez-Sanchez despite a federal request to detain him for possible deportation.

Lopez-Sanchez, 45, was previously deported five times to his native Mexico.

Republican presidential front-runner Donald Trump has repeatedly mentioned the killing of Steinle as he calls for a border wall and mass deportations to curb illegal immigration.

California Sen. Dianne Feinstein and presidential hopeful Hillary Clinton, both Democrats, said Lopez-Sanchez should have been detained.

Sheriff Ross Mirkarimi said his department was following city law when jailers released Lopez-Sanchez after a 20-year-old marijuana possession charge was dropped.

The sheriff said his department requires federal officials to obtain a warrant or some other judicial notice in order for his jail to hold an inmate facing possible deportation.

San Francisco and some 300 other cities and counties have passed so-called sanctuary laws of non-cooperation with federal immigration officials seeking to detain jail inmates suspected of being in the country illegally.

Prosecutors want to convict Lopez-Sanchez of second-degree murder, which carries a maximum sentence of life in prison.

His public defender Matt Gonzalez argues that the shooting was an accident and his client should be tried for manslaughter rather than murder. The maximum sentence for an involuntary manslaughter conviction is six years.

Lopez-Sanchez says he found the gun used in the shooting of Steinle under a bench on Pier 14. He said the gun accidentally fired when he picked it up.

Ballistic experts testified last week that the bullet ricocheted off the pavement before striking Steinle in the back.

The gun had been reported stolen from the car of a Bureau of Land Management ranger in June.

Steinle's family has filed three separate legal claims seeking unspecified damages from the BLM, San Francisco Sheriff's Department and the U.S. Department of Homeland Security.

The three agencies declined to comment on the claims, which are precursors to lawsuits.