Sen. Kamala D. Harris, proud of being one of the only presidential candidates to spend Thanksgiving in Iowa and not at home, invited reporters into her temporary residence in Des Moines on the holiday to show off her turkey preparation skills.

What she didn’t say at the time was that she was also having intensive conversations with her husband, her sister Maya Harris and Maya’s family as the tightknit group grappled with whether there was any path forward for her campaign.

The talks extended into late Monday night, as Kamala Harris stayed up until 2 a.m. futilely trying to find a way to push on. But Tuesday around 12:45, she called her staffers to tell them it was all over.

It was a sobering finish to a once-dazzling campaign. Harris (D-Calif.) proved an uneven campaigner and was ultimately engulfed by low polling numbers, internal turmoil and a sense that she was unable to provide a clear message amid the roiling, impassioned politics of the moment.

And it marked a long, painful fall from her January kickoff, when Harris ran onstage to electrify a crowd of more than 22,000, the embodiment of Democratic hopes that she represented one of their best chances to beat President Trump — a rising female star with a mixed-race background who could rebuild the coalition that propelled Barack Obama.

Instead, Harris’s departure is the latest surprise in a Democratic primary that has repeatedly defied prediction, with several prominent senators, as well as candidates of color, struggling in a political landscape marked by anger, passion and a desperate Democratic desire to unseat Trump. The other early star of the campaign, former congressman Beto O’Rourke (D-Tex.), dropped out a month ago.

In a note to supporters Tuesday, Harris stressed her campaign’s financial struggles as the driving force behind her departure. “I’ve taken stock and looked at this from every angle, and over the last few days have come to one of the hardest decisions of my life,” she wrote. “My campaign for president simply doesn’t have the financial resources we need to continue.”

Some Democratic activists saw Harris’s departure as a troubling sign that minority candidates are not faring well despite the party’s ostensible sensitivity to diversity.

“No matter your candidate, you have to recognize that going from the most diverse field ever in January to a potentially all-white debate stage in December is catastrophic,” said Leah Greenberg, co-founder of Indivisible, a left-leaning coalition. “We need leaders who represent the diversity of our party.”

The news came as a particular shock to backers who that very morning had announced a super PAC to support Harris’s candidacy. Some donors spent the day frantically trying to retrieve hundreds of thousands of dollars they had wired into the super PAC’s account.

One of Harris’s biggest backers, Quinn Delaney, had even approved a large transfer of funds to pay for an Iowa television ad from the new super PAC — a fact unknown to the Harris staffers as they prepared to pull the plug.

Harris’s exit kicked off a scramble to sign up her erstwhile supporters, staffers and donors. Fifteen members of Congress had publicly backed Harris, including several prominent minority members.

Moments after the news broke, South Carolina state Sen. John L. Scott Jr. (D), a Harris backer, said he began receiving calls, and even an in-person visit, from other campaigns jockeying for his support. “My phone hasn’t stopped ringing,” he said.

Bernice Scott, a prominent African American leader in South Carolina who also endorsed Harris, described a similar experience. She said her “Reckoning Crew” of mostly black female activists would soon decide how to proceed.

Harris remains a potentially appealing running mate for the eventual Democratic nominee. Unlike the senators staying in the race, she will be free to spend January focused on Trump’s expected Senate impeachment trial, the sort of high-profile event in which she has thrived in the past.

For months, Harris swatted away any suggestion that she would have to settle for a running-mate slot. For a long time, even as she dropped in polls, she continued to draw crowds and enthusiasm.

But an aide said an assessment of the campaign’s finances conducted over the weekend found that after raising about $12 million in each of the year’s first three quarters, the operation was failing to keep up that pace, raising just “a fraction” of that amount this quarter.

That left Harris without money to spend on ads in Iowa and elsewhere, essentially forcing her hand. “I think it just sort of got to a head,” said one adviser, speaking on the condition of anonymity to discuss private conversations. “She really did a sober analysis.”

Harris plans to travel to the early-primary states this week to thank her staff and supporters.

The withdrawal also follows months of internal turmoil in Harris’s campaign, which lacked a clear decision-making structure and often left aides feeling caught between influential figures such as Maya Harris, her sister and campaign co-chair, and campaign manager Juan Rodriguez.

Rodriguez faced criticism inside the campaign over his handling of finances and other issues. Multiple people affiliated with the campaign said its financial difficulties had forced recent cutbacks in advertising, travel and staffing.

Harris’s campaign ended months before the first primary votes were cast — and as several lesser-known candidates continued to chug along.

When the campaign launched in January with a big rally in her hometown, Oakland, her star power appeared to symbolize the country’s diversity, an inclusive Democratic Party and a rebuke to the Trump vision.

Her perch on the Senate Judiciary Committee, meanwhile, showcased her interrogations of prominent Republican nominees, such as Supreme Court pick Brett M. Kavanaugh and future attorney general William P. Barr.

But the campaign arguably peaked during the first Democratic debate, when Harris challenged former vice president Joe Biden over the way he had talked about his onetime relationship with segregationist senators.

On Tuesday, Biden appeared taken aback by her exit. “I have mixed emotions about it,” he told reporters, calling Harris a “first-rate candidate” and “a solid, solid person.”

Overall, little about this Democratic primary has gone as expected. Harris’s Senate colleague Kirsten Gillibrand (N.Y.) quit the race in late August, joining several governors and House members who also left the stage after making barely a ripple. In contrast, Pete Buttigieg, the formerly little-known mayor of South Bend, Ind., has proved a fundraising powerhouse and a top-tier candidate.

Inside the Harris campaign, staffers concede that her early buzz masked the reality that few Americans knew her. A lack of a clear message and her up-and-down debate performances led to fluctuation in the polls, which in turn yielded uneven fundraising. At one point her campaign hired two dozen people in New Hampshire, only to fire them two months later.

The campaign had been banking on the same path to the nomination that is being pursued, with more success, by Biden.

Harris hoped a strong showing in Iowa would give her momentum heading into the South Carolina primary a few weeks later. That, in turn, would have propelled her into Super Tuesday on March 3, when an array of states vote, including Harris’s home state of California and several others with large African American populations.

But Biden has attracted more support than Harris from black voters, some of whom are wary of Harris’s career as a prosecutor. Meanwhile, others have questioned the ability of an African American woman to win the presidency.

Her campaign sought to reset itself on several occasions, most recently by announcing it would focus almost entirely on Iowa, where Harris has ventured at least once a week since the beginning of October. But polls there show the increased emphasis yielded little progress, while firings and resignations marred the comeback attempt.

Harris’s Senate term ends in 2022, meaning she will soon enter another election cycle, assuming she is not picked as vice president or attorney general if a Democrat wins the White House.

Scott, the South Carolina activist, said she was disappointed by Harris’s decision but respected it, adding, “You’ve got to know when to hold them and know when to fold them and know when to walk away.”

Annie Linskey, Sean Sullivan and Michael Scherer contributed to this report.