SAN FRANCISCO — As a scandal rocked the city’s crime lab in 2010, District Attorney Kamala D. Harris was increasingly at odds with the city’s elected public defender, Jeff Adachi. He accused her of being “unethical,” and she said he was “playing politics with public safety,” according to media reports at the time.

The fight was, on one level, an example of a prosecutor and defense attorney playing their respective roles. But it was all the more extraordinary because the two had been friends for years.

Adachi had been Harris’s tutor when they were at the University of California’s Hastings College of the Law in San Francisco. Their relationship continued as their careers intersected at crucial moments, often on opposite sides in high-profile criminal cases, until it recently reached an unexpected conclusion just when she may have most needed his help.

They were children of the Bay Area. Adachi developed his fervent sense of justice from Japanese American parents who had been sent to an internment camp by the U.S. government during World War II. Harris, whose father came from Jamaica and whose mother is from India, grew up attending civil rights rallies in Berkeley.

Both decided that the way to address injustice was to work within the system — he as a public defender and she as a prosecutor. Both experienced disillusionment in their early jobs that led them to seek political office. Adachi was elected as the city’s chief public defender in 2002, and Harris ran the following year to be district attorney.

One day, Adachi ran into Harris and asked her why she wanted to focus on the prosecutorial side of the law.

“And she said, ‘That’s how I’m going to change the world,’ ” Adachi said in a recent interview. “My perception is that she saw law enforcement as the place she would have the greatest amount of influence because you know as D.A., she would be the one making the decisions” on whether to prosecute individuals. “People saw the system as the enemy, so joining the system was a tightrope walk.”  

Harris won in 2003, and for all seven years that she served as district attorney, Adachi was on the opposite side. They continued as adversaries and friends, often talking to each other about cases, and seeking support from the same set of voters.  

“We grew up together as professionals,” Harris, 54, said in an interview. Given his status as one of the few elected public defenders in the country, Adachi was “a real national leader” with “a bully pulpit,” she said. Adachi also wrote and directed a documentary called “The Slanted Screen,” which was critical of the way Asians have been stereotyped on television and in movies. 

Adachi, a fit-looking man with an even-keeled but forceful tone, sometimes questioned whether Harris was going far enough in her promise to look out for the rights of defendants as well as prosecuting them. He urged her to speak more about the need for changes in sentencing, bail and prisons. 

“Could she have been more progressive given that she was a prosecutor of color? Yeah,” Adachi said. “Did I hope that? Yeah, at times. Was I disappointed? Yeah, but at the same time, you know, I saw her as somebody who was in a position to make a difference.” He recalled discussing cases with Harris in which she agreed to go more lightly on deserving defendants. 

After six years in which their offices faced off, the relationship hit perhaps its roughest moments when it was revealed in March 2010 that Harris and her staff had not informed defense lawyers that evidence from the police-run crime lab might have been tainted. A judge ruled in May 2010 that Harris had failed to inform defendants as required by law. Harris said in the interview she took responsibility and made “no excuses” for the failure.

It was during that time that Adachi told the San Francisco Chronicle that Harris was being “unethical” for not disclosing to defense attorneys that police officers who were essential to certain cases had been convicted of crimes or been investigated for misconduct. He said Harris “is putting the privacy interests of police officers who have misconduct records and who have been convicted of crimes above the rights of citizens to a fair and honest trial.”

Harris fired back that Adachi was “playing politics” and said records were overseen by the police and protected by state privacy rules.

Adachi, after running unsuccessfully for mayor in 2011, continued as public defender. Harris had greater ambition and broader success, winning election as California attorney general and U.S. senator. But as she declared her candidacy for the presidency, critics on her left raised concerns about her record on criminal-justice reform and questioned whether her characterization of being a “progressive prosecutor” was inherently contradictory.

As a result, Harris wanted support from Adachi, whose endorsement would have been an ideal response to such concerns. But Adachi wasn’t quite ready.

On Feb. 13, as he sat for an interview in his spacious second-floor office, he spoke carefully, saying he admired Harris but had questions about how committed she was to instituting changes to help defendants.   

“The big question that I have now, which I’m trying to get answered — and I actually have a call in to her, I don’t even know if I’ll hear back — is . . . I want to know what you’re going to do in the future. She says that one of her planks of her platform is going to be criminal-justice reform. What does that mean?” 

The following day, Harris said, Adachi told her on the phone that reporters were asking him questions about her record. She said she told Adachi that she was committed to ensuring that defendants receive their constitutional rights, and she asked him to be an adviser on the issue for her campaign. 

It was an emotional call, she said. They discussed their three decades of friendship, going back to law school and their respective roles in San Francisco’s tumultuous criminal-justice system.  

“I had a great conversation with him, and he was very supportive,” Harris said, while saying she didn’t ask for a formal endorsement. She said he agreed to have a subsequent talk with the campaign about formalizing his role as an adviser. 

Eight days later, Adachi, 59, died after having dinner with a friend. An official report has not been released, but local media reported the cause of death as a heart attack.   

Harris still seemed in disbelief. “I was very sad that he died, and I still am,” she said, her voice trailing off. No longer could she count on the plan that Adachi would again counsel her, just as he had 30 years ago.