Before Trump, before the Kavanaugh hearings, the book tour, the “she’s running” memes, the California senator Kamala Harris sat in St Mary’s Cathedral in San Francisco amid a sea of blue-uniformed police officers.

The year was 2004, just a few months into Harris’s first term as San Francisco district attorney – her first elected position. A young police officer, Isaac Espinoza, had been gunned down on the job, and the city’s rank-and-file were out for blood.

Harris had unseated the incumbent (albeit unpopular) district attorney in part by campaigning to not seek capital punishment. Three days before the funeral at St Mary’s, Harris announced that she intended to keep her campaign promise, much to the fury of the police. But as she sat in the cathedral, the woman who would later become her colleague, Senator Dianne Feinstein, veered from the script and called for the death penalty, prompting thousands of officers to their feet.

Harris remained sitting.

I’ll hand that to her. Her ambition is without equal Steve Cooley, former LA district attorney

To this day, some city police officers will still clench their teeth when Harris’s name comes up in conversation, recalling what they describe as a betrayal 15 years prior.

But Harris took the political hit. She stayed the course, as she always had in her meteoric rise in San Francisco and California politics. Her career has been dotted with moments like the one in St Mary’s, but her track record shows that she has grand ambitions and a plan on how to achieve them, making both friends and enemies along the way.

And now, as she eyes the highest office in the land, few doubt her ability to eventually get where she wants to go.

“Nobody works harder than Kamala Harris,” said Lateefah Simon, Harris’s longtime friend. “She’s a strategist. She has a memory like nobody you’ll ever meet. But more than that, I think she cares. She cares about what happens in the lives of the people in our community.”

San Francisco has long been considered a liberal bastion, but it’s taken time for the city’s power structure to reflect the diversity of the people. But until Harris was elected district attorney in 2003, only white men had held that office.

Born in Oakland in 1964, at the height of the Bay Area’s anti-war and civil rights activism, she was bussed to an elementary school in Berkeley as “part of a national experiment in desegregation”, according to her political memoir, The Truths We Hold.

Her parents – Shyamala Gopalan, an Indian immigrant, and Donald Harris, who was born in Jamaica – would often bring her to marches and protests at UC Berkeley.

Facebook Twitter Pinterest San Francisco city hall. Kamala Harris got her start in the city’s political world. Photograph: Tayfun Coşkun/Anadolu Agency/Getty Images

After her parents divorced, Harris and her younger sister, Maya, who would go on to become a senior adviser to Hillary Clinton during the 2016 presidential campaign, were primarily raised by their mother. Harris attended high school in Montreal, where her mother had a job teaching at McGill University, and went on to study at Howard University before returning to the Bay Area for law school at UC Hastings.

There, she met Jeff Adachi. Later on, as the city’s public defender, he would face off with Harris as her chief in-court adversary when she became the city’s top prosecutor. But at UC Hastings, he was just a tutor.

“Even then, she was an extremely talented, charismatic person who had a very strong ambition. That was something that struck me right away,” Adachi said. “She was always a people person, as she is now, but always very focused on whatever it was that she wanted.”

In her last summer in law school, she went on to intern at the Alameda county district attorney’s office, where she spent a few years after she passed the bar. She later went on to the San Francisco district attorney’s office as a line prosecutor, eventually taking over the office’s career criminal unit.

“I remember asking her why she wanted to be a prosecutor,” Adachi said, “and she said, ‘That’s how I’m going to change the world.’”

In 1994, Harris met then state assembly speaker Willie Brown, a controversial figure in California politics.

Facebook Twitter Pinterest San Francisco mayor Willie Brown in 1999. Photograph: Dan Krauss/AP

Back then, he was called the “Ayatollah of the Assembly”. In San Francisco, a city defined by its great wealth and even greater economic disparities in part because of its rich history of political back-scratching, he’d go on to be known by many names: “Da Mayor” (he was mayor of San Francisco from 1996 to 2004); the kingmaker; the puppetmaster.

Anybody in Brown’s orbit is considered part of the Willie Brown machine – which, depending on who you ask, is either merely an influential, moderate-leaning branch of the California Democratic party, a self-serving cartel with the lobbying and fundraising skills to make or break careers, or both.

Brown’s proteges soar high, but the whispers follow. This rang especially true for Harris, who dated Brown for about a year. He was 60 and she was 29. During this time, Brown appointed her to the state Unemployment Insurance Appeals Board and the California Medical Assistance Commission, both high-paying positions.

Many politicians owe their success to Brown. He launched the careers of California’s governor, Gavin Newsom, the former California state senator Mark Leno, and the former San Francisco mayor Ed Lee, but when discussing Harris, the talk gets particularly nasty, in part because of their romantic history.

Harris has spent much of the past 25 years distancing herself from Brown – she doesn’t mention him once in her political memoir. But much like he did for Newsom and Leno, Brown opened doors. And when it came time for her to run for district attorney after a stint working in the city attorney’s office, she won.

Kamala Harris: can a 'top cop' win over progressives in 2020? Read more

“In those days, when you were supported by Willie Brown, it came with all the support and money of the San Francisco establishment,” said Aaron Peskin, a current member of the San Francisco board of supervisors.

In San Francisco, where only less than 7% of all registered voters are registered Republican, the political spectrum spans mostly between moderate and progressive Democrat. Peskin, a longtime progressive stalwart in city government with healthy skepticism of Willie Brown’s influence, found himself aligned with Harris, despite their political differences.

“I was an early enthusiast for Kamala Harris for district attorney, even though I’m a self-professed leftie and she came from the Willie Brown moderates,” Peskin said. “All things being equal, I’d rather have a district attorney that is independent of the mayor [Brown was still mayor at the time Harris was elected]. Mayors want to have influence over the legislative body, but how often do mayors call upon the district attorney?”

Play Video 2:46 Senator Kamala Harris announces 2020 presidential bid - video profile

Harris ran for district attorney at a contentious time for the office. The incumbent, Terence Hallinan, a prominent progressive, had unsuccessfully tried to indict the entire command staff of the San Francisco police department.

Hallinan was unpopular, but it was still shocking for a first-time candidate to beat not just a sitting official, but also a serial candidate for district attorney, Bill Fazio.

“She had a lot of support,” said Fazio, a former prosecutor and the third candidate in the race. “She was a new face, an attractive candidate, and I don’t just mean in a physical sense. For San Francisco, she fit in well. She had connections through Willie Brown. She was introduced to a lot of moneyed people.”

Harris had campaigned on the promise to repair relations between her office and the embattled police department – and then, on her 100th day in office, there she was in St Mary’s Cathedral, watching as thousands of cops cheered against her. Peskin had attended the funeral and remained seated as well, and remembered seeing her a few rows in front him, her face ashen.

“It was so hard and painful,” said Lateefah Simon, Harris’s longtime friend. “She was new to the office and she had always been clear: she was anti-death penalty. But you know, I never saw Kamala bow her head down in any kind of shame. I think during this time, she began to deeply understand the power of her voice and how she could move through situations.”

Kamala Harris is the toughest person that you’ll ever work for. But everybody is forever transformed Lateefah Simon, friend and colleague

A few months later, Harris called Simon up and asked her if she wanted to run her re-entry services. Simon told Harris it would be risky to hire her, “a teen mom with no college degree”. (Simon is selling herself short here – she is the youngest woman to receive the prestigious MacArthur Fellowship). But Harris refused to let Simon settle, and part of her employment agreement included the requirement to get her degree. “She made me show her my report cards!” Simon laughed.

“Listen, Kamala Harris is the toughest person that you’ll ever work for,” Simon said. “She is just a zealot about public service, and it’s intense. But everybody who works for Kamala is forever transformed. I know it’s not just me. There were many others.”

Harris regularly put in 12- to 14-hour days, talking to victims’ families “and promising them justice”, Simon said. She held her employees to high standards, but herself to even higher ones.

“One day, she had a really bad cold,” Simon said. “It was like the flu. She had tissues, but she was still impeccably dressed, and she had a bowl of clementines on her impeccably organized desk. It was like 4.50pm. I said, ‘Ms Harris’ – because I always called her Ms Harris when I worked for her – ‘it’s almost quitting time, and you’re sick.’ She took a sip of water, looked at those bowls of clementines and then looked me dead in the eyes and said, ‘I don’t get sick.’”

Facebook Twitter Pinterest Kamala Harris asks questions during a Senate intelligence committee in 2017. Photograph: Jim Lo Scalzo/EPA

Harris has received criticism for her record as district attorney, for which she was re-elected in 2007. While Harris has been outspoken about her progressive values on police reform and criminal justice, her critics say her time as district attorney does not reflect that.

“In many respects, she was a traditional prosecutor, concerned with conviction rates and victims’ rights,” Adachi said. “This was before the criminal justice reform movement and Black Lives Matter had really taken hold, and she pretty much ran the office as you would expect a prosecutor to run an office. But she was also open to programs that helped individuals turn their lives around.”

One of the biggest missteps of her tenure as district attorney arose as she was running for attorney general in 2010. Ahead of the primary, the San Francisco police department became embroiled in a scandal. A criminalist at the department admitted to regularly stealing cocaine from evidence. The woman also implicated other analysts in poor investigative work, resulting in the dismissal of hundreds of pending cases.

A superior court judge pilloried Harris’s office in a scathing ruling on the case and essentially accused her office of violating defendants’ constitutional rights by not informing them of the issues, as prosecutors are obligated to.

Entering the race with this scandal hanging overhead, the odds were against Harris.

Yet she won. The race was so close that it was not until three weeks after the election and the provisional ballots were counted that the former Los Angeles county district attorney Steve Cooley conceded.

“You got to remember, Kamala Harris is all politics all the time,” Cooley said. “There’s no question when it comes to being a politician, she is very committed and hardworking, whereas I was a career prosecutor. I never perceived myself as a politician.”

Nine years later, Cooley still expresses some bitterness over the loss, and Harris’s criminal justice record, saying that he’s heard from “many elected DAs” around the state who believe she was “the worst attorney general ever”.

Who will run in 2020? The full list of Democrats vying to take on Trump Read more

But underneath the bitterness is a grudging respect.

“She looked at everything she did as DA from a political prism,” he said. “Attorney general is a pretty powerful position in California. I think when she was DA, she was already looking at it as the next step up the ladder. Watch her now. She’s in the Senate and now apparently she’s going for president.”

He laughed. “I’ll hand that to her. Her ambition is without equal.”

Ambitious women get a bad rep in this world, especially ambitious politicians who are women, and Harris and her supporters have heard it all. Calculating. Untrustworthy. Unlikable. “This is what happens when you have a dynamic and gifted woman of color who goes into her job and does her job,” Simon said.

Bill Fazio, the attorney who Harris defeated in her first race for district attorney, still balks when he hears people describe Harris as “guarded” or “cold” because he knows that she is anything but that.

Facebook Twitter Pinterest Kamala Harris at San Francisco’s gay pride parade in 2018. Photograph: Josh Edelson/AFP/Getty Images

In March 2009, Fazio’s wife died and out of the blue, he received a call from Harris. “Her mom passed away about the same time, and she was very close to her mom.” Fazio said. “All she wanted to do was to talk about our personal losses in a very personal way.”

He continued: “People always call me up thinking I’m going to trash her. But I still feel really positive about her.”

In a prime example of the insular and small-world nature of San Francisco politics, the San Francisco supervisor Aaron Peskin and Harris had not only attended Thousand Oaks elementary school together in Berkeley, but were in the same class from kindergarten through third grade. “Her mother was Shyamala, from India, and my mother was Tsipora, from what was then Palestine, now Israel,” Peskin said. “It’s a total Bay Area story.”

When Peskin’s father died in April, he was surprised to get a text message from Harris containing a snapshot of a class book they had put together as kids with the message: “Thinking of you.”

It’s telling that even her former adversaries are reluctant to speak too badly of her, in part because many believe that like every other goal she’s met in her life, she’s destined for higher office, whether in this race or the next.

But for more, there’s an aspect of game recognizing game. No matter the criticism of Harris, no one can deny that she stayed the course, in a time when few have the necessary discipline, dedication or political knowhow to do so.

“She didn’t come from a place of privilege or money,” said Adachi, the public defender. “She wasn’t a Kennedy. She had to work hard to get to where she is. A lot of people say she coasted into the Senate position. No, it was because of the political capital she built from those other races. And since then, she has been able to take the political capital, and amplify it. And she’ll do it for every office she’ll run for.”