Sen. Kamala Harris is pinning her presidential hopes in part on her career experience as a prosecutor. But while “Kamala Harris: For the people” is a catchy slogan, it could cause problems in that nuance-free whirlpool known as a presidential campaign.

Start with the controversy around Harris’ first major decision as San Francisco’s district attorney: deciding not to seek the death penalty for a gang member who fatally shot police Officer Isaac Espinoza in 2004.

Harris’ Democratic primary opponents probably won’t bring it up, as they all oppose the death penalty, just as Harris does. But should the California Democrat survive the primary battle, you can bet President Trump’s first TV attack ad will include some version of this riff: “As San Francisco’s district attorney, Kamala Harris refused to seek the death penalty for a gang member who killed a police officer.”

“At some point, Harris will have to respond to that,” said Markos Moulitsas, founder of the influential DailyKos progressive blog. “How she handles that will go a long way to determining how far she goes in the campaign.”

On MSNBC’s “The Rachel Maddow Show” Wednesday, Harris said she “absolutely” would welcome a national debate on the death penalty with Trump.

“We are talking about a system that creates a final punishment without any requirement that there be DNA to prove it,” Harris said. “It is a system where it has been fundamentally proven to be applied to African American and Latino men and poor men disproportionately for the same kind of crime.”

Harris said that in her experience as a prosecutor, it was not a deterrent to crime.

“Nobody ever stood there and was about to pull the trigger and then decided, ‘Hmm. Is this going to be life without the possibility of parole or the death penalty?’ ” Harris said.

She didn’t mention the Espinoza case in her new memoir, “The Truths We Hold” — a forum that would have allowed her to explain her reasoning on her terms. Now, Harris will have to spend time on the campaign trail explaining the nuances in some of her stances as a prosecutor — starting with what happened on the night before Easter Sunday in April 2004.

Espinoza was on patrol in San Francisco’s Bayview neighborhood when David Hill, a gang member, shot him to death with an assault rifle. Espinoza, 29, was a popular and charismatic officer who had turned down chances to transfer to a safer part of town. He told family members it was because he wanted to serve “the good people who live there.”

Three days after Espinoza was slain, Harris said she would not seek the death penalty.

Harris’ decision was both surprising — and not. She had campaigned as a death penalty opponent and said she would not seek capital punishment in any trial if she won. The stance wasn’t controversial in San Francisco, where 70 percent of voters typically oppose capital punishment on state ballot measures and juries almost never send convicts to Death Row. Her opponent, then-District Attorney Terence Hallinan, opposed it, too.

The surprise was that the rookie district attorney made her announcement so soon after Espinoza was gunned down. Typically, prosecutors wait weeks after an arrest to make such decisions.

“I want to be very clear,” Harris told reporters when she said she would seek life without parole for Hill. “In the city and county of San Francisco, anyone who murders a police officer engaged in his or her duties will be met with the most severe consequences.”

The most severe consequence would have been death. At the time, prosecutors in California had sought the death penalty in nearly every one of the 90 cases since 1987 in which a police officer had been killed, according to a Chronicle investigation at the time.

Law enforcement officials were outraged by Harris’ call.

“I’m sorry, I just think (this crime is) as bad as it gets and deserves the punishment as bad as it gets, and that’s the death penalty,” California Highway Patrol Commissioner Dwight “Spike” Helmick, current president of the California Peace Officers Association, said at the time.

Gary Delagnes, then the head of the San Francisco Police Officers Association, said that “in most cities in America, this would be a death penalty case.” But he added that life without parole “is as much as we can expect in this town.”

The toughest political blow for Harris happened at Espinoza’s funeral. She was sitting in the front of St. Mary’s Cathedral when Sen. Dianne Feinstein, the city’s former mayor, rose to address the congregation. Indirectly, she called out Harris.

“This is not only the definition of tragedy, it’s the special circumstance called for by the death penalty law,” Feinstein said. The congregation, filled with uniformed law enforcement officers, stood and roared approval.

Afterward, Feinstein said that if she had known Harris opposed the death penalty, she wouldn’t have endorsed her for district attorney.

At the time, Feinstein’s statement rocked the political establishment. She was the state’s most powerful politician, the rare pro-death penalty Democrat, and Harris was three months into her political career.

But Feinstein’s scolding was also odd, since Harris never hid her opposition to the death penalty during the campaign. And Feinstein told the Los Angeles Times last year that she herself now opposes the death penalty.

Hill eventually was convicted and sentenced to life in prison.

For Harris, the political damage from the case was swift and lasted years. No police unions endorsed her 2010 campaign for state attorney general, in which she barely defeated Los Angeles County District Attorney Steve Cooley. Soon after taking statewide office, however, she sought to repair the relationship. She traveled the state to try to reach out to law enforcement groups.

Her outreach got results: Several rank-and-file unions endorsed her 2014 re-election, including the Peace Officers Research Association of California, which advocates and provides training for 64,000 public safety officers.

But Harris’ death penalty stance remained complex. She promised voters that she would uphold state law as attorney general, and she successfully appealed a federal judge’s 2014 ruling that the death penalty was unconstitutional because of its lengthy appeals process.

Harris argued that the judge’s ruling “undermines important protections” for defendants. A progressive critic of Harris, University of San Francisco law Professor Lara Bazelon, called her reasoning “unfathomable.”

“It’s like she was trying to provide a legal argument to the liberal anti-death-penalty crowd,” Bazelon said.

Harris still smarts about the initial political blowback to her decision in the Espinoza case. As she told Maddow on Wednesday, there were “high-level elected Democrats who said the case should be taken away from me because I would not seek the death penalty.” Among those Democrats: then- Sen. Barbara Boxer.

“I did what I believed was the right thing to do,” Harris said. “And the killer of that officer will be in prison for the rest of his life.”

But that is unlikely to be the end of the story.

Joe Garofoli is The San Francisco Chronicle’s senior political writer. Email: jgarofoli@sfchronicle.com Twitter: @joegarofoli