A jury’s near-full acquittal in the Pier 14 killing of Kate Steinle shocked many people who expected a conviction for murder or at least manslaughter. After all, there was no dispute that the accused man held the gun that fired the fatal bullet and that he hurled the weapon into San Francisco Bay as Steinle lay dying.

But the prosecution was, in some ways, fighting uphill from the start, legal experts said Friday, one day after Jose Ines Garcia Zarate was convicted only of a single count of being a felon in possession of a firearm.

“You have to prosecute a case with the evidence you have, and that’s what the prosecution did,” said Hadar Aviram, a criminal law professor at UC Hastings College of the Law in San Francisco. “I think in this case, there just wasn’t the evidence.”

City authorities never overcame a critical obstacle and established a motive that would explain why the 45-year-old homeless undocumented immigrant — whose release from San Francisco jail before the shooting under the city’s sanctuary policies became a national controversy — would want to kill a stranger.

And though prosecutors believed Garcia Zarate brought the semiautomatic pistol to the waterfront on July 1, 2015, they had little evidence to counter the defense assertion that he found the gun in a T-shirt or cloth and picked it up, causing it to fire accidentally. The gun had been stolen four days earlier from the nearby parked car of a federal ranger, but the burglary remains unsolved.

The defense had little evidence supporting its account, either, but the burden was on the prosecution to prove guilt beyond a reasonable doubt.

President Trump called the verdict “a complete travesty of Justice” on Friday and — echoing of a number of conservative pundits — suggested that the jury should have been told that Garcia Zarate “came back and back over the weakly protected Obama border, always committing crimes and being violent.”

But while Garcia Zarate has been deported five times and has drug convictions in the U.S., he has no violent convictions. And evidence of prior criminal history — and by extension, poor character — is generally not admissible in U.S. courts, unless it is directly relevant to the current case.

Garcia Zarate was charged with murder from the beginning, and prosecutors gave jurors three options.

They could convict on first-degree or premeditated murder. They could opt for second-degree murder, requiring a finding that Garcia Zarate either intended to kill Steinle or intentionally committed a dangerous act with conscious disregard for human life. Or they could choose involuntary manslaughter, which would require a finding that Garcia Zarate caused Steinle’s death with an unlawful, negligent act.

To prove murder, Assistant District Attorney Diana Garcia needed to convince jurors that the round that killed Steinle had been fired intentionally. But this was a difficult task as the bullet first struck the pier’s concrete 12 to 15 feet from Garcia Zarate, then bounced and traveled 78 more feet to strike Steinle in the back as she strolled with her father.

“The evidence that Kate Steinle was killed with a ricochet shot, rather than a direct shot, makes it even tougher to prove to the jury beyond a reasonable doubt that it was an intentional killing,” said attorney Jim Hammer, a former city prosecutor.

Throughout the trial, attorney Matt Gonzalez of the public defender’s office sought to characterize the ricochet as proof that Steinle’s death had been a tragic accident that befell a hapless man.

With no direct accounts from eyewitnesses or surveillance video showing Garcia Zarate’s actions during the shooting and in the moments just before, what remained were dueling conclusions drawn from circumstantial evidence.

And in California, the law on circumstantial evidence swings in the defense’s favor. Jurors are instructed that if they “can draw two or more reasonable conclusions from the circumstantial evidence, and one of those reasonable conclusions points to innocence and another to guilt, you must accept the one that points to innocence.”

“That’s a tough hurdle for a prosecutor to overcome,” Hammer said. “I think for those who are outraged by this verdict, they have to remember that the defense didn’t have to prove that it was an accident. All they had to do was raise reasonable doubt and that there was some other reasonable scenario.”

Jurors declined requests to explain their thinking as they left the city courthouse Thursday.

Garcia offered evidence that the pistol that killed Steinle would fire only with a firm pull of the trigger. She pointed at the defendant’s actions after the shooting — tossing the firearm and walking away — as an implication of guilt. The prosecutor called to the stand a crime scene inspector, who testified that he believed Garcia Zarate had to have aimed the gun toward Steinle for the bullet to have followed the path that it did.

And she played clips of Garcia Zarate’s four-hour police interrogation for the jury. But his alleged confession included a variety of stories about what happened, some conflicting with each other and physical evidence.

Garcia Zarate’s attorneys attacked the interrogation, and they countered as well by calling an expert who testified it was unlikely that such a ricochet shot was intentional. They contended that Garcia Zarate tossed the gun in the bay because he was frightened.

“We have to deduce how a stranger was thinking at the time of the crime from various external evidence,” Aviram said. “It’s not a question of who the jurors believe more. They have to be very close to 100 percent certain that he had intent in order to convict. And they were not.”

It’s unclear whether the prosecution’s trial strategy backfired. Garcia spent most of the trial laying the groundwork for a second-degree murder charge, but in her closing remarks, she introduced a possible motive in a bid for first-degree murder, saying Garcia Zarate had been “playing his own secret version of Russian roulette” when he brought a loaded firearm to a “target-rich environment.”

However, throughout the six-week trial the prosecutor presented little evidence to support that theory, only calling to the witness stand a tourist who was at the pier the day of the shooting and who testified that Garcia Zarate gave her an uneasy feeling.

In his closing arguments, Gonzalez said the case should not have been charged at all, hinting that the political uproar caused by Garcia Zarate’s immigration status had pushed prosecutors — who deny the claim — to seek a harsher punishment.

“Prosecutors don’t always pursue cases in which they’re certain of the outcome,” Aviram said.

Alex Bastian, a spokesman for the district attorney’s office, said the case “made its way to a trial courtroom for a reason. ... At every stage, there was sufficient evidence.”

Hammer noted that the jury spent six days in deliberations, suggesting their decision was not rushed and that they carefully weighed the evidence.

“You may not like the outcome, but if you put 12 strangers into a room and they all agree on something, you need to respect that,” Hammer said. “I don’t think it was an easy decision. I think they knew they were going to walk out and get criticized. But they were the 12 who had that responsibility, and that was what they did.”

Garcia Zarate is scheduled to return to court Dec. 14, and when he is sentenced faces up to three years in state prison — a term he has likely already satisfied since his arrest. Federal authorities on Friday unsealed a warrant for his arrest related to his immigration status, and plan to deport him for a sixth time.

Vivian Ho is a San Francisco Chronicle staff writer. Email: vho@sfchronicle.com Twitter: @VivianHo