Sen. Kamala D. Harris (D-Calif.) had two big moments when she questioned Supreme Court nominee Brett M. Kavanaugh at his volatile confirmation hearing two years ago.

The first was when she pressed the nominee on whether he knew of any laws that tell a man what to do with his body, as abortion laws do for women, flustering Kavanaugh and prompting him to say he did not.

She also pushed him on whether he had discussed the Mueller investigation with anyone at a law firm linked to President Trump — adding ominously, “Be sure about your answer, sir.” Kavanaugh appeared mystified and ultimately said no, leaving Republicans furious and Democrats unsure what Harris was getting at.

Those moments illustrate the power Harris’s prosecutorial skills have to energize Democrats and elevate her profile, but also the risk for controversy she faces in high-profile hearings like these.

Starting Monday, Harris will again be at the center of an explosive nomination battle — this time in an unprecedented role as a member of a presidential ticket participating in a divisive Supreme Court hearing just three weeks before Election Day.

As Joe Biden’s running mate, she faces an especially delicate task: appearing tough enough to satisfy liberals upset with Amy Coney Barrett’s nomination but restrained enough to support Biden’s outreach to disillusioned Republicans.

At the same time, she is auditioning as a possible future president. “If I were Kamala Harris, I would try to [give] off the most presidential demeanor possible,” said Mike Davis, a Republican Judiciary Committee counsel during the Kavanaugh hearings. “Her job is to be presidential.”

Harris’s aides say she will leave the campaign trail this week to focus fully on the hearing. Despite her national profile, Harris will be among the Judiciary Committee’s most junior members at a potentially raucous proceeding where everyone will be masked, several senators facing reelection will need to score points and some members are expected to participate remotely because of coronavirus infections.

In many ways, the stakes are higher this time. Barrett’s confirmation would create a 6-to-3 conservative majority on the Supreme Court, an outcome Democrats warn would threaten abortion rights, the Affordable Care Act, LGBTQ protections and more.

Two years ago, Harris faced a different challenge as one of several Democrats on the Judiciary Committee contemplating a 2020 presidential run, including Sens. Amy Klobuchar (Minn.) and Cory Booker (N.J.). Harris became a face of the Democrats’ resistance to Kavanaugh, especially after she asked whether he knew of any laws that dictate a man’s use of his body.

Kavanaugh appeared stumped. “I’m happy to answer a more specific question, but . . .” he trailed off. Harris prodded: “Male versus female?” After more back-and-forth, Kavanaugh conceded, “I’m not thinking of any right now, senator.”

The second inquiry was whether Kavanaugh had spoken about the then-pending Mueller investigation to any member of the Kasowitz Benson and Torres law firm, whose co-founder Marc Kasowitz had represented Trump.

Kavanaugh, appearing uncertain what Harris was getting at, initially stumbled over his answer but ultimately said no. A Harris spokeswoman at the time said the senator had reason to believe Kavanaugh had ties to the firm, though she did not provide details.

Republicans said angrily that Harris had overstepped, fabricating a nonexistent “gotcha,” and Trump continues to blame Harris for what he calls the “suffering” Kavanaugh endured at the hearing.

“Sen. Kamala Harris was the one who grilled then-Judge Kavanaugh on a wild conspiracy theory that he was colluding with a lawyer at a law firm regarding the Mueller probe,” said Davis, the former judiciary counsel. “It was completely baseless, and she knows it was completely baseless.”

Kavanaugh has not been Harris’s only target. In May 2019, Attorney General William P. Barr appeared before the Judiciary Committee, and Harris asked whether Trump — or anyone else at the White House — had ever suggested he open an investigation of someone.

Barr hesitated, saying, “I wouldn’t . . .” then asked her to repeat the question. As he searched for an answer, Harris said pointedly, “Seems you’d remember something like that.”

Ultimately, Barr said he could not answer the question, and Democrats cheered the exchange as revealing potential ethical concerns and what they considered Barr’s inappropriate closeness with the White House.

But Sen. Christopher A. Coons (D-Del.), a close Biden ally, said Harris’s prosecutorial reputation overshadows a broader, less polarizing role that she plays in less noticed Judiciary Committee hearings.

“The world off the committee really only pays attention to the committee when there’s a high-profile fight,” Coons said, but “you have hearings on things as diverse as antitrust, intellectual property, immigration, gun violence and judicial nominees.”

He added, “Sen. Harris is someone who always does her homework. She’s prepared. She’s thorough. And she’s often one or two steps ahead of the witness.”

Harris also sits on the Senate Intelligence Committee, which holds many of its hearings behind closed doors, a setting that tends to minimize performative partisan posturing. Sen. Mark R. Warner (Va.), the committee’s top Democrat, said Harris has won her colleagues’ respect in those closed sessions.

“People don’t stand for grandstanding, and there’s also some good-natured back-and-forth — more than you’d see in a public setting,” Warner said. “But she came in tough and earned her stripes right away. Even very conservative Republicans realized she did her homework and knew her stuff.”

Warner and Coons noted that Harris, whose election to the Senate in 2016 makes her one of its most junior members, is for that reason among the last to ask questions at any committee hearing.

“One of the challenges of being a junior member of the committee, as I remember from a decade ago, is often by the time it gets to you, three-quarters of what you wanted to ask has already been asked,” Coons said.

Aides say Harris often prepares a handful of potential inquiries, then crosses off questions and recalibrates as her colleagues cover that ground. Often, aides say, Harris ends up posing queries she has thought of or reframed during the hearing itself.

Before most consequential hearings, Harris’s staff prepares briefing binders, often prompting her to ask for more information. Once she has it, she and her staffers bat around potential lines of questioning.

Harris’s former chief of staff, Nathan Barankin, remembers Harris before the Kavanaugh hearing, sitting in a room full of aides — “rocket-scientist lawyers who went to Harvard, Yale and practiced before the U.S. Supreme Court”— as they strategized about how best to interrogate the nominee.

Harris at one point halted the discussion. “Can anyone here name for me another Supreme Court case that dictates to a man what he may or may not do to his body?” Barankin remembers her asking. Nobody could think of one, and that led to Harris’s pointed question to Kavanaugh.

When it comes to the Barrett nomination, Harris has been more willing than Biden to warn it could imperil reproductive rights if Barrett joins a majority to overturn Roe v. Wade, the landmark 1973 decision guaranteeing abortion rights.

But Harris and Biden have sounded louder alarms about the threat to the Affordable Care Act, whose constitutionality will come before the Supreme Court shortly after the election.

That could be a focus of Harris’s questioning at the upcoming hearing, aides say, adding that Senate Democratic leaders will largely determine their party’s strategy. “I don’t expect any input from the Biden campaign,” Coons said.

Those familiar with early plans say, given Harris’s high profile, she will probably try to hammer home a big-picture message rather than focusing on details.

She has already rejected accusations from Republicans who charge that Democrats have shown an anti-Catholic bias against Barrett — an assertion made by Vice President Pence at the recent vice-presidential debate.

“Joe Biden and I are both people of faith, and it’s insulting to suggest that we would knock anyone for their faith,” Harris responded. “In fact, Joe, if elected, will be only the second practicing Catholic as president of the United States.”

While the setting is familiar, this will be an entirely different experience for Harris.