When Kamala D. Harris first ran for public office in 2003, she took on the incumbent district attorney for whom she had worked. He was nicknamed Kayo, as in K.O. for knockouts, and he attacked her mercilessly, questioning whether she would investigate corrupt politicians.

Harris coolly turned the attack against her former boss with a devastating rhetorical counterpunch, suggesting she might even investigate him. She won.

Now, as Harris is set to debate Vice President Pence on Wednesday as the Democrats’ vice-presidential nominee, the lessons she learned from her first campaign reveal the birth of a political brawler. It is an approach she has honed ever since, and it has come to define her blunt-force, prosecutor-like manner of taking on an opponent.

“Kamala has shown her mettle over time in terms of being able to fend off unwarranted and scurrilous attacks, of which I’m sure there will be many” before the election, said Jim Stearns, a consultant on her 2003 campaign for San Francisco district attorney, which he said “absolutely” prepared her for the fights to come.

In that race, Harris became the first woman and the first African American to be elected district attorney for San ­Francisco, and she later broke the same barriers to become attorney general of California. Now she’s seeking to become the first vice president who is female or a person of color. Wednesday’s debate will be the most visible test of her career-long effort to break campaign molds by forcefully presenting her views and challenging opponents.

Harris plans to spend much of the debate highlighting differences between President Trump and Democratic nominee Joe Biden, rather than confronting Pence, according to people familiar with her plans and preparation.

An aide said that Harris will probably follow the lead set by Biden, who has acknowledged that he doesn’t want to levy personal attacks at Trump while he is ill but has criticized Trump’s handling of the pandemic and other policy-related choices.

Harris won election to the U.S. Senate in 2016 after blitzing her opponent in a debate for missing votes. Her national profile rose in 2018 with her questioning of Supreme Court nominee Brett M. Kavanaugh. In framing a question about a woman’s right to an abortion, she asked whether he knew of any law that gives the government control over a man’s body.

Kavanaugh seemed speechless before he conceded, “I’m not thinking of any right now, Senator.” Trump called her questioning “extraordinarily nasty.”

Then, in a Democratic primary debate last year, she attacked Biden’s position against federally mandated busing to integrate schools, saying she had benefited from it as a young girl. Biden eventually picked Harris as his running mate, but the strike was so strong that it initially turned some Biden associates against her.

It is a style that was shaped in that first race as a candidate, in which she audaciously ran against the man who hired her in 1998, San Francisco District Attorney Terence “Kayo” Hallinan.

Harris began working for Hallinan as an assistant district attorney, prosecuting homicides and other criminal cases. She later wrote that the office was “self-destructing” and that “violent offenders were walking free.”

She left in 2000 for a job in the San Francisco City Attorney’s Office, running the family and children’s services division, before deciding in 2003 to run against Hallinan. A third candidate, Bill Fazio, joined the race.

Harris wrote in her autobiography, “The Truths We Hold,” about how daunting the race seemed to her, especially taking on her former boss, who “had a reputation as a fighter.”

“A campaign would be not only bruising but also expensive, and I had no experience as a fund-raiser,” Harris wrote. She decided to run after mulling the words of the Black author James Baldwin, who had said, “The challenge is in the moment; the time is always now.”

Line of attack

Harris, who was 38 years old at the start of the race, was relatively unknown at the time, with only 6 percent of voters saying in initial polls that they had heard of her.

Still, her opponents, Fazio and Hallinan, recognized the threat she posed and viewed her association with a political legend, former speaker of the California State Assembly and San Francisco Mayor Willie Brown, as a line of attack to try to end her candidacy.

Harris and Brown dated in 1994 and 1995. Brown urged her to consider a political career and — in a move that generated much controversy in San Francisco politics — appointed her to two state boards, for which she was paid $400,000 over five years, according to news reports at the time.

In mid-1994, Brown appointed Harris to a $97,000-a-year job on the Unemployment Insurance Appeals Board, but that position expired at the end of the year, the Los Angeles Times reported in 1994. She took a leave from her full-time position as an Alameda County prosecutor while she served on the board, according to reports.

Then, just before leaving his post as speaker, Brown in November 1994 appointed Harris to the California Medical Assistance Commission, a part-time position that the Los Angeles Times said paid $72,000 a year.

The Brown-Harris romance ended in late 1995, but the repercussions of the alliance played out more fully when Harris ran for district attorney. Her opponents questioned the propriety of her acceptance of the positions from Brown and sought to raise doubts about whether she would investigate possible corruption in Brown’s mayoral administration.

An investigation by the San Francisco Chronicle of what it called “Willie Brown Inc.” revealed that Brown’s administration had created 350 mayoral “special assistant” jobs with a $45 million payroll. City Hall was investigated by the FBI for at least five years starting in 1998 as part of a wide-ranging probe into municipal corruption, but no charges were brought against him. Brown and his allies dismissed the criticism and said he had been vindicated.

Fazio sent a mailer to voters that showed a woman saying of Harris, “I don’t care if Willie Brown is Kamala Harris’ ex-boyfriend. What bothers me is that Kamala accepted two appointments from Willie Brown to high-paying, part-time state boards — including one she had no training for — while being paid $100,000 a year as a full-time county employee.”

Harris told SF Weekly at the time that Brown was “an albatross around my neck” but said she was torn over how to respond. SF Weekly said “the charge is that she is Brown’s puppet” and suggested that she could win her race only “if she can just get out from under this damn Willie Brown thing.” Just the mention of Brown, the Weekly’s reporter wrote, made Harris’s “shoulders tense, her hands clench, and her eyes narrow.”

Harris told the Weekly that not only was she independent of Brown, but also “he would probably right now express some fright about the fact that he cannot control me.” If she was elected and discovered corruption occurred under Brown, “it will be prosecuted.”

Responding to Fazio’s mailer, Harris sent a recorded telephone message to voters that sought to explain what she did on the boards on which she served. She said in the message that her work on the unemployment commission enabled her to help extend benefits to gay couples, and that her service on the California Medical Assistance Commission enabled her to keep open a hospital.

Stearns, the former Harris campaign consultant, said Fazio’s attack backfired.

“We never had a poll that showed Kamala in anything but third place, but she was climbing steadily, and that attack on her was the catalyst to put her over the top,” Stearns said. Voters were turned off by the negativity “and decided that if this is the only thing wrong with Kamala Harris, she’d be a pretty good choice.”

Brown, in a recent interview with The Washington Post, said he saw nothing inappropriate in appointing Harris to the state panels. He said he saw no conflict in appointing her at a time he had a relationship with her.

“You have to select people to serve on boards and commissions,” he said. “And it’s really difficult to find people who are sincere enough to do the job because it’s a thankless task.”

Harris and her campaign spokeswoman declined a request for comment. She has defended her work on the panels and has said that raising questions about her association with Brown is sexist. She told the Los Angeles Times in 2015 that “My opponents chose to tell a story that was salacious and made it sound like I didn’t do anything of my own merit, that I was a creation of somebody,” a charge she said was untrue.

Fazio failed to secure enough votes in the initial round of voting, setting up a runoff between Hallinan, who had narrowly led the first round, and Harris. Fazio said in an interview that he agreed with Stearns’s assessment that the ad “backfired on me.” In retrospect, Fazio said, “Brown helped a ton of politicians,” and he said he doesn’t think her service on the boards was problematic, saying it was how such “plum” appointments are often handed out.

Stepped-up attacks

The runoff only heightened the focus on the Brown-Harris relationship, as Hallinan stepped up the attacks.

Harris had initially said she would support Hallinan but decided to run against him after observing what she called a lack of professionalism in the office. Hallinan was considered one of the nation’s most liberal prosecutors, and Harris — who today says she was a “progressive prosecutor” — ran to Hallinan’s right.

During a debate, Hallinan said Harris should not be elected because she wouldn’t investigate corruption. Speaking of Brown, Hallinan said: “He has an interest in having a friend in the district attorney’s office.”

Harris, in a fiery response that foreshadowed her political style, responded: “I will set up a public integrity desk dedicated to dealing with investigating and prosecuting cases involving corruption by any public official — be it Terence Hallinan or anyone else.”

“That really takes my breath away,” Hallinan said.

Harris, who emphasized in a campaign mailer that every person who had held the office had been a White man, won the race in the December 2003 runoff with 56 percent of the vote.

Brown appeared at the victory celebration at Harris’s headquarters, telling the San Francisco Chronicle that “It is obviously a gender victory. It is obviously an ethnic victory. But it was her competence that defeated Terence Hallinan.” Hallinan died earlier this year.

Reflecting on her election in her autobiography, Harris wrote that she was inaugurated on the same day as Gavin Newsom became mayor, recalling a “palpable sense in the city that a new chapter was opening for San Francisco politics — and what might be possible for us all.”

Brown, meanwhile, has continued to dispense political advice to Harris. In an Aug. 8 column for the San Francisco Chronicle, he wrote that Harris should reject the vice-presidential slot if it was offered. He suggested she instead seek to be U.S. attorney general and then president.

But after Harris accepted Biden’s offer and followed his introduction with powerful remarks, Brown said she will play a vital role in helping Democrats win back the White House. The best thing Biden can do, Brown said, is to get out of her way and “let her do her thing.”

Alice Crites and Chelsea Janes contributed to this report.