The question came from out of the blue in 2021, as Gov. Gavin Newsom of California was on television, fending off a campaign to recall him. If Senator Dianne Feinstein left office before the end of her term, Joy Reid of MSNBC wanted to know, would the governor rectify a glaring gap in representation and name a Black woman to fill the seat?

On tape, the governor’s own eyes seemed astonished by what his mouth was about to do to his political options.

“We have multiple names in mind,” Mr. Newsom said. “And the answer is yes.”

Two and a half years later, that pledge — along with a second televised remark in September calling it an “interim” appointment — would box Mr. Newsom into one of the most complex personnel decisions of his tenure, forcing him to juggle competing political agendas from Capitol Hill to California, including his own national aspirations.

When Senator Feinstein died last week, Mr. Newsom had already made it clear that he did not want to appoint Representative Barbara Lee, a Black woman running in next year’s Senate race, because he said he did not want to interfere in the contest. But Mr. Newsom also wanted to avoid frustrating Nancy Pelosi, the former House speaker, who has put her considerable muscle behind the candidacy of Representative Adam Schiff. And Mr. Newsom did not consider Ms. Lee, one of the most liberal members of the California delegation, to be an ideological match for his own politics, as he increasingly tacks to the middle.

If he chose someone to serve only as a caretaker, however, Mr. Newsom would upset Black leaders, who were already questioning his commitment to ensuring that Black women would have their voice in the Senate restored for years, not months. And as Mr. Newsom eyes a future run for the White House, he can ill afford to upset Black voters, who have been crucial in early primary states.

The two national interviews were classic examples of how Mr. Newsom has at times let his exuberance get the best of him, going further in the moment than his political strategists considered wise.

“He got all tangled up in his spurs,” said David Townsend, a longtime Democratic political consultant based in Sacramento who does not work for Mr. Newsom. “This is why advisers always tell politicians to avoid hypotheticals. But he always wants to say the right thing, right?”

Mr. Newsom seems to have resolved matters for now by naming Laphonza Butler, 44, the president of Emily’s List and a longtime California labor leader, to replace Senator Feinstein. The governor assured Ms. Butler that it was up to her whether to try to keep the seat by running in next year’s election. Though it had appeared earlier that any appointment he made would be tarnished with resentment and recrimination, Democrats celebrated the governor’s choice this week with palpable relief.

When she was sworn in by Vice President Kamala Harris in Washington on Tuesday, Ms. Butler became the third Black woman ever to serve in the Senate and the first lesbian to represent California in the chamber.

Ms. Butler, a savvy political operator, has not committed herself either way regarding the 2024 race.

Advisers to the governor, who spoke on condition of anonymity in order to recount the details of Ms. Butler’s selection, said that Mr. Newsom’s spur-of-the-moment pledges to name a Black woman as an interim replacement put him in a quandary.

Black women are a key constituency in the Democratic Party, and their support is considered essential to Democrats who hope to rise nationally. Black leaders have emphasized lately how vital Black voters were to reviving President Joe Biden’s campaign in South Carolina in 2020.

But California’s electorate features a dizzying array of political and ethnic groups that lobby hard for representation, and satisfying one faction inevitably means upsetting several others. Only about 5 percent of California’s population is Black, a far smaller share than those of Latino, white or Asian American residents.

To many Black leaders, including the Congressional Black Caucus, Mr. Newsom’s choice was clear: He had to appoint Ms. Lee, a longtime icon in the Black community.

But Mr. Newsom had internal Democratic Party politics to consider as well, and naming Ms. Lee would have given her a significant advantage in the 2024 Senate race. Mr. Schiff, who led the investigation of the Jan. 6, 2021, attack on the Capitol, was the choice of Ms. Pelosi. And the other leading contender, Representative Katie Porter, is popular among progressives and women.

When Ms. Feinstein was homebound with a bout of shingles in the spring, the governor began making a mental shortlist of potential replacements, his advisers said.

The list included Mayor Karen Bass of Los Angeles; Mayor London Breed of San Francisco; Shirley Weber, the state elections chief; Holly Mitchell, a member of the Los Angeles County Board of Supervisors; and a few judges and leaders in academia and at think tanks in California.

Ms. Butler, whom Mr. Newsom had once considered hiring as his chief of staff, was also on the list, advisers to the governor said. And she was initially asked to suggest more names, something Mr. Newsom had often sought from her when he was considering high-level appointments.

But the most prominent Black women in state elective office were hesitant. Some were reluctant to give up their existing seats for what appeared to be a time-limited Senate appointment, or to undermine Ms. Lee.

Mr. Newsom’s second complicating interview came last month on the NBC program “Meet the Press,” when he said that he would only replace Senator Feinstein with an interim appointee.

Ms. Lee, 77, took immediate umbrage.

“The idea that a Black woman should be appointed only as a caretaker to simply check a box is insulting to countless Black women across this country who have carried the Democratic Party to victory election after election,” she said in a statement.

Mr. Newsom’s team was taken aback by the strong rebuke from Ms. Lee, several of his advisers said, and the situation was tense enough that two of his longtime strategists resigned from a political action committee they were organizing for the congresswoman.

Ms. Lee’s camp continued to push hard behind the scenes, asserting to Mr. Newsom that she was the only logical choice. With the Congressional Black Caucus backing Ms. Lee and few other powerful Black officeholders showing interest, the pool of viable nominees was shrinking by the day.

Black leaders had at least two grievances with the governor. First, after Ms. Harris, then the only Black woman in the Senate, was elected vice president, Mr. Newsom appointed Alex Padilla, a Latino, to replace her. That elevation and endorsement had probably installed a Latino politician in the Senate for decades to come, and they wondered why Mr. Newsom was hesitating to do the same for a Black woman.

Second, they took issue with the possibility that Mr. Newsom would tap a Black woman as a caretaker, only to see the seat won next year by one of the white candidates, Mr. Schiff or Ms. Porter, who have led in polls and fund-raising.

Mr. Newsom’s circle was unusually tight for his deliberations. He could not easily turn to his usual advisers at the Bay Area firm Bearstar Strategies because at least two of the firm’s principals have been working for Mr. Schiff. Other longtime advisers were helping Ms. Lee, while his political spokesman was in Ms. Porter’s camp.

Senator Padilla said in an interview that he spoke with Mr. Newsom more than once after Ms. Feinstein died, mostly about the need to appoint a replacement quickly given the narrow Democratic edge in the chamber. Several people familiar with the deliberations said that as a potential government shutdown loomed until Saturday, Senator Chuck Schumer, the majority leader, had pushed for a speedy appointment as well.

Deliberations continued last weekend as interest groups began to bear down and Black female public officials, including some on Mr. Newsom’s short list, said publicly that they did not want the appointment.

“I never take anything in which I don’t think I can make a difference, and being a senator for a year, I probably couldn’t accomplish an awful lot,” Ms. Weber, the secretary of state, said in an interview.

Then came a twist: Mr. Newsom’s office clarified that he actually was not averse to a candidate who might enter next year’s race.

By early Sunday evening in California, word began to circulate that the governor had chosen Ms. Butler. She had moved to Maryland in 2021 when she took the Emily’s List position, but said she would return to Los Angeles and register to vote as a Californian.

Ms. Butler needs to decide soon whether she will run in 2024. The filing deadline is in December and, practically speaking, a serious statewide campaign in California ought to have started at least six months ago.

Mr. Newsom said on Monday that he is “not interested” in whether she runs. “I have an incredible appointee and she’ll make a decision with no constraints, no expectations,” he said.

Michael Tubbs, a special adviser to Mr. Newsom and a board member of Emily’s List, said the board met with Ms. Butler on Monday, and that it was not clear whether they should seek a short-term replacement or a permanent one.

“If her family agrees, she should definitely run,” said Mr. Tubbs, a former mayor of Stockton, Calif. “I hate this idea we can choose who can run and who can’t. The voters need to decide.”

Among those Ms. Butler spoke with over the weekend to seek counsel was Vice President Harris.

As for Ms. Butler, she said in a statement to The New York Times on Tuesday that “saying yes was a big decision, and I genuinely have not decided anything beyond that.”