SAN FRANCISCO — The undocumented immigrant accused of shooting and killing Pleasanton native Kate Steinle was aiming toward her and knew what he was doing, a prosecutor argued Monday at the start of a politically charged murder case that sparked a nationwide debate over immigration policy.

But a defense attorney said Steinle’s death was the result of an accidental gunshot and a “freakish ricochet” of the bullet that struck her.

The trial of Jose Ines Garcia Zarate, who allegedly shot 32-year-old Steinle on San Francisco’s Pier 14 in July 2015, kicked off on Monday with opening statements and brief but emotional testimony from Steinle’s father, who was walking with her during the shooting.

The closely watched case has attracted national attention because of its connection to immigration policy — Garcia Zarate, a Mexican citizen, was released from a San Francisco jail two and a half months before the shooting instead of being deported because of the city’s sanctuary city policy. Republican presidential candidate Donald Trump and other conservatives seized on the shooting as an argument for tougher immigration laws.

But inside Courtroom 13, the focus was on ballistics, not politics. Neither side in the trial referred to the political furor surrounding the shooting, and Garcia Zarate’s immigration status was barely mentioned.

Garcia Zarate, 45, has pleaded not guilty to second-degree murder, and his lawyers argue that the shooting was an accident — a single shot that ricocheted off the pier into Steinle’s back. The prosecution will try to convince jurors that Garcia Zarate shot recklessly at people, the standard necessary for a second-degree conviction.

Assistant District Attorney Diana Garcia started her at times dramatic opening statement by lifting up the gun, a plastic tag through its trigger.

She described the “beautiful summer afternoon” that Steinle, her father, and a family friend took a walk in San Francisco’s Embarcadero neighborhood. The group passed by Garcia Zarate on the pier, she said.

Garcia Zarate, who was spinning around in a chair on the pier, aimed “towards” Steinle with the gun and fired, Garcia argued. Steinle, who was walking with her father, fell forward.

“The only thing she could say was ‘dad, help me, help me,'” Garcia said. “Those would be her last words.”

She pointed to her own back, showing where the bullet hit Steinle.

Previewing what’s expected to be a heavy focus on the gun, a Sig Sauer P239, Garcia spent time explaining how the firearm worked and discussing how it got into Garcia Zarate’s hands. It was issued to a federal Bureau of Land Management agent who was on his way driving with his family from Southern California to Montana, and was stolen from his car. There’s no evidence that Garcia Zarate stole it, and he told police he found it on the pier.

Defense attorneys have argued that the gun may have misfired, but Garcia said it had been checked by the bureau’s armory three months before the shooting and was in perfect working order.

“It’s a very reliable, high-quality gun,” Garcia said. “It’s not the kind of gun that’s going to go off by accident.”

She acknowledged that the shooting was a ricochet skip shot, hitting the pier about 15 feet from the defendant and then ricocheting almost 80 feet farther to hit Steinle. That’s a key piece of evidence the defense points to as proof that Garcia Zarate wasn’t trying to hit her. But Garcia said that firearms experts will testify that he could have been aiming toward her while raising the gun and pulled the trigger before the weapon was high enough.

“He knew all along what he was doing,” Garcia said.

Defense lawyer Matt Gonzalez, the chief attorney in the San Francisco Public Defender’s Office, argued that Steinle’s death was an accident.

“Only a freakish ricochet, which altered the course of the bullet, caused this tragedy,” Gonzalez said. “An expert marksman could not have made this shot if he or she tried.”

He said Garcia Zarate, who was homeless, had found the gun on the pier, wrapped in a cloth, and picked it up. “He did not know he was handling a firearm,” he said.

Gonzalez also painted a very different picture of the weapon in the case, which he said has a history of accidental discharges even among law enforcement officials trained to use it. He showed jurors images of the gun manual, reading them warnings about the dangers of keeping it unsecured.

Gonzalez analyzed individual frames of an extremely grainy surveillance video shot from a nearby fireboat, arguing that it showed Garcia Zarate bending down near his chair on the pier.

Jurors also heard excerpts of the rambling, four-and-a-half-hour interview police had with Garcia Zarate the day of his arrest.

In his brief testimony, Steinle’s father James recalled the day of the shooting, when he and a family friend visited his daughter in San Francisco. The group had walked along the Embarcadero and “stopped and watched the birds and the boats” on Pier 14, he remembered. Kate snapped photos, including a selfie of the smiling group, which was shown to the jury.

The idyllic scene ended with a loud bang or pop, James said, and Kate fell forward. At first, as he tried to help her, he didn’t realize she had been shot.

“She was having trouble breathing and I couldn’t figure out what happened,” he said, his lower lip trembling uncontrollably.

Garcia Zarate, wearing a striped button-up shirt, listened to a simultaneous Spanish translation of the proceedings through large headphones.

Steinle’s mother and older brother sat in the front row of the stuffy, windowless courtroom. Two of Garcia Zarate’s family members were also present.

The jury, which was selected last week, comprises six men and six women, including three immigrants.

The trial is expected to take between six weeks and two months.