When Kamala D. Harris became San Francisco’s district attorney 16 years ago, one of her top priorities was to fight federal policies that she believed put too many Black people in prison.

Some of those objectionable policies — including incentives to build more prisons and lock more people up for longer periods of time — had been enacted in the 1994 crime bill, written by then-Sen. Joe Biden (D-Del.).

As it turned out, the path that the senator from California and the former vice president took to finding common ground on criminal justice reform was a key factor in bringing them together on the Democratic presidential ticket at a moment when such reform is considered an urgent task amid the rise of the Black Lives Matter movement, Harris’s advisers said.

As Harris makes history as the first Black woman named to a major-party ticket, Biden has moved markedly closer to her viewpoint, acknowledging that key parts of his crime bill “went wrong” and vowing to undo it.

If the Democratic ticket is elected, “this could be a game changer” for instituting criminal justice reform, said Lara Bazelon, a professor at the University of San Francisco School of Law, who previously has been critical of Harris’s claim that she was a “progressive prosecutor.”

Still, as she takes on the role of running mate and as every detail of her life becomes subject to intense examination, Harris, 55, is bound to face questions about her career as a prosecutor and the degree to which she and Biden, 77, are truly in sync on a crucial issue.

Biden once said that “it doesn’t matter whether or not” criminals “were deprived as a youth,” while Harris has written about criminals who were “marked for a bleak future solely because of the circumstances of their birth.”

Biden once said the answer to fighting crime is that criminals “must be taken off the street,” while Harris has said one of the gravest injustices of recent decades is that this has become “an era of mass incarceration.”

Lateefah Simon, whom Harris hired in 2004 to help institute a program to reduce incarceration rates, learned that some of the policies Harris sought to reject had been written by Biden.

“It was her job to undo bad policy,” Simon said in an interview. Moments after hearing that Harris had been picked as Biden’s running mate, Simon said, “Can you imagine that we are going to have a vice president that is a Black woman, who carries a migrant story of her mother, who has been trying to undo the criminalization of poor people and immigrants for her whole career?”

A profound impact

From the earliest days of her career, Harris has faced questions about why she decided to go into law enforcement and spend years as a prosecutor, instead of working to defend those mistreated by the criminal justice system. She was, as she has told it, constantly asked why she would go to work for “the man,” meaning the law enforcement system. Even her own family questioned the decision, requiring Harris to explain why she believed that “law enforcement has such a profound and direct impact on the most vulnerable among us,” as she put it in an interview with The Washington Post last year.

As the daughter of a Black father and an Indian-born mother, Harris’s racial and political identity has long been a central part of her story. She grew up in the liberal bastions of Oakland and Berkeley and was wheeled in her stroller to civil rights rallies, where she has said she learned to shout the word “freedom” (pronouncing it “feedom” when she was a toddler).

Harris famously was part of the second group of children in her neighborhood to be bused to an elementary school in a mostly White area as part of a plan to racially integrate classes, an experience that she cited during a debate last year when she charged that Biden opposed such busing. “That little girl was me,” Harris said. Biden responded in the debate: “I did not oppose busing in America. What I opposed is busing ordered by the Department of Education.”

Harris has said her mother imbued her two daughters with Indian culture but made an extra effort to raise her and her sister as “proud Black women.” Harris attended a historically Black college in Washington, Howard University, and joined the nation’s oldest Black sorority. Asked how her Black heritage influenced her, she told The Post last year that “it affects everything about who I am,” including her awareness of racism against people like her as well as those of other races and religions.

Harris’s time at Howard foreshadowed her political rise. Soaking up the political atmosphere in the nation’s capital, she volunteered for the 1984 presidential campaign of Walter Mondale, who made history by picking a woman, Geraldine Ferraro, as his running mate, but lost by a wide margin to President Ronald Reagan.

Harris then attended the University of California’s Hastings College of the Law in San Francisco, where she was tutored by Jeff Adachi. He later became the city’s elected public defender, often putting him at odds with Harris during her time as district attorney. After graduating in 1989, Harris served for eight years as the deputy district attorney in Alameda County, prosecuting an array of crimes in the Oakland area.

It was in the midst of that work that Biden won approval of his crime bill. In her 2009 book, “Smart on Crime,” Harris wrote that liberal politicians in the late 1980s and early 1990s “were terrified of being branded as soft.”

While she didn’t mention Biden, the then-senator from Delaware said on the Senate floor in 1993 that he was not one of those “wacko liberals” who only wanted to look at the causes of criminal behavior and that he was tired of seeing Democrats portrayed as weak on crime.

After eight years in Oakland, Harris took her work across the bay and served in various roles in the San Francisco city attorney’s office from 1998 to 2004, then became a top deputy for District Attorney Terence Hallinan, who called himself the country’s most progressive prosecutor.

But Harris became disenchanted with Hallinan’s performance, resigned from her position and eventually launched a campaign against her former boss.

Adachi, the former tutor who became public defender, recalled asking Harris why she wanted to become district attorney.

“And she said, ‘That’s how I’m going to change the world,’ ” Adachi recalled in an interview with The Post last year in San Francisco shortly before he died. “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 initially was given little chance of becoming district attorney. Every previous district attorney in San Francisco had been a White male. No African American had ever been elected to such a job in California.

Hallinan, whose father, Vincent, had run for president in the Progressive Party in 1952, was the most liberal candidate in the three-person field. Harris ran to Hallinan’s right, asserting that he was unprofessional and too soft on crime. She won the race and took office in 2004.

'The definition of tragedy'

Harris had said during the campaign that she opposed the death penalty — a position that seemed unremarkable until she stunned the city by winning the election.

Three months after she took office, two undercover police officers were on patrol in the Bayview neighborhood. The city was experiencing a gang-related crime wave, and the officers were following a suspect. Suddenly, the 21-year-old suspect fired an AK-47 assault rifle, killing Officer Isaac Espinoza, 29.

Espinoza’s partner, Barry Parker, was wounded in the left foot.

The following morning, Easter Sunday, Harris went to police headquarters to follow the progress of the case. She talked on the phone with Parker and helped oversee the investigation. Calls soon rose, including from some liberal Democrats, for Harris to seek the death penalty. She attended the funeral, sitting in the front row, and later said she was stunned when Sen. Dianne Feinstein (D-Calif.) suggested during her speech at the church that the death penalty was appropriate in the killing of a police officer.

“This is not only the definition of tragedy, it’s the special circumstance called for by the death penalty law,” Feinstein said, prompting a standing ovation from hundreds of officers.

“It was a very intense emotional environment that day in the church,” Harris told the San Francisco Chronicle after the funeral. “People were mourning very deeply, so I was well aware that they were not happy with my decision.”

When Harris stuck to her campaign vow, saying she would seek life in prison for the killer, the police officers union that had endorsed her said it regretted having done so.

Parker, the wounded partner, told The Post last year in a rare interview that “I was disappointed. But she had her feelings about it. That was her decision to make.”

Espinoza’s widow, Renata, told CNN last year that Harris’s action still upset her, recalling that the prosecutor didn’t call her to say she wasn’t seeking the death penalty. “She was only thinking of herself,” Renata Espinoza said. “I couldn’t understand why. I was in disbelief that she had gone and already made her decision to not seek the death penalty for my husband.” She could not be reached for comment.

Jim Stearns, who had been Harris’s campaign manager, said that despite the controversy, her approval rating doubled to about 70 percent. She was now one of the most well-known politicians in California, and she faced crises that kept her in the news, starting with a string of murders that plunged the city into a new cycle of fear.

In this atmosphere, her calls to be tough on crime received as much notice as her pleas to reform the system. It was years before the Black Lives Matter movement, although Harris gave voice to some of its future themes. She emphasized her program called Back on Track, which was designed to help nonviolent offenders avoid returning to prison.

By the time she sought reelection in 2007, Harris had repaired her relationship with the police department and won support for her reform program. She said she had increased the felony conviction rate from 52 percent to 68 percent. The onetime long shot was now considered unbeatable, and no one ran against her. Soon, she launched a statewide campaign for attorney general.

Then a new crisis emerged that threatened to derail her aspirations.

Harris’s office had brought thousands of cases against drug offenders, an unpopular position among many in famously liberal San Francisco. But a police investigation found problems with test results at a crime lab that dealt with the cases. One of Harris’s deputies wrote an email saying that a crime lab technician had become “increasingly UNDEPENDABLE for testimony,” and weeks later the technician allegedly took home cocaine from the lab.

Harris, who said she was initially unaware of the issues, did not inform defense attorneys of the problems. She was excoriated for this failure by Superior Court Judge Anne-Christine Massullo, who wrote in May 2010 that Harris had “failed to disclose information that clearly should have been disclosed.” The judge said individuals in Harris’s office “at the highest levels” knew that the crime lab technician was not a dependable witness.

In casting herself as a “progressive prosecutor” — a phrase designed to soothe voters who may be uncomfortable with her law enforcement background — Harris has surprised some who worked closely with her at the time. They remember her waging a tough campaign against a more liberal opponent whom she disparaged as being too soft on criminals, and they don’t recall her initially fighting for some of the reforms that she now presents as cornerstones of her career.

“Did she distinguish herself as a prosecutor who was not for mass incarceration?” Adachi said shortly before he died. “Not really. No. Was she railing against racial injustice in the current justice system? Not really. I mean I’m sure she was aware of the issues because we were saying them, but no one wanted to hear this stuff.”

Harris wound up dismissing hundreds of cases handled by the crime lab. In an interview with The Post last year, she took responsibility for her office’s failures in the scandal. While noting that the police ran the lab, she said in the interview: “My No. 2 knew about it, my office knew about it, and I took full responsibility and take full responsibility. No excuses.”

Harris won the general election, vowing to make criminal justice reform the centerpiece of her term.

A progressive evolution

Harris was elected attorney general of California in 2010 and 2014 and oversaw an office of more than 4,500 people. After facing much criticism for refusing to call for the death penalty in the Espinoza case, she took a hands-off approach in her new position, saying that was a local decision. A Democratic presidential primary opponent, Rep. Tulsi Gabbard (Hawaii), charged in a debate last year that Harris “blocked evidence from being revealed that would have freed” some death row inmates “until you were forced to do so.”

Harris responded in the debate that she has opposed the death penalty her entire career and never sought it when she prosecuted cases.

She also was criticized for failing to endorse a measure that would have required police shootings to be investigated by a special prosecutor, a position that put her in harmony with police unions but at odds with reformers.

Asked why she didn’t endorse the legislation, Harris said during a primary debate last year that “I did not oppose the bill” but that, as attorney general, she did not think she should be “weighing in on bills” for which she had responsibility to write the title and summary.

In 2016, after a career walking a fine line between being a prosecutor who cracked down on criminals and a reformer who wanted to lower incarceration rates, she ran successfully on that record to win election to the Senate. She had presumed she would take her seat during a Hillary Clinton administration, but instead she has spent her entire service in Washington during the era of President Trump. Instead of being able to push through her agenda, she has spent much of the past four years fighting Trump’s.

Bazelon, the University of San Francisco law professor who questioned Harris’s credentials as a progressive prosecutor, has seen a change in her since she came to Washington. In California, Bazelon said, Harris “didn’t want to legalize marijuana, she didn’t want her office as attorney general to investigate officer-involved shootings.” But Bazelon said that as a senator, Harris has “evolved” and is now much more progressive.

She has, for example, supported legalization of marijuana, a position that Biden has not fully embraced but has been inching toward. He said during the campaign that marijuana is a “gateway drug” but that it has to be legalized, an off-the-cuff remark that did not amount to a formal endorsement.

In the end, the growing movement to embrace criminal justice reform, and the backlash against Biden’s work on the 1994 crime bill, helped lead the former vice president to pick Harris as his running mate.

“Not only Joe Biden but the Democratic Party itself has evolved quite significantly over the last decade, and Senator Harris has been a trailblazer on the issue of criminal justice reform,” said Brian Brokaw, who ran Harris’s campaign for California attorney general and remains an adviser. “I think the two of them are very much in line in how they see the world and the change that has to be made in that respect.”

From the moment she took her Senate seat, Harris has said that her top goal is to oust Trump. She had hoped to be the one to be replace him, but after a burst of initial enthusiasm for her presidential bid, she faltered, and her attacks on Biden over criminal justice and other matters didn’t stop his drive to the nomination.

Now the two onetime rivals are on the same ticket, having largely bridged their political divide, united in their desire to return the White House to a Democratic administration.

Alice Crites contributed to this report.