MANCHESTER, N.H. — Sen. Bernie Sanders narrowly won the New Hampshire primary Tuesday, Feb. 11, consolidating support on the left and fending off a late charge by two moderate rivals to claim his second strong showing in two weeks and establish himself as a formidable contender for the Democratic nomination.

Sanders had about 26% of the vote with 80% of the ballots counted, while former Mayor Pete Buttigieg of South Bend, Indiana, was a close second. Buttigieg split the centrist vote with Sen. Amy Klobuchar of Minnesota, who surged in New Hampshire to finish in third.

Sen. Elizabeth Warren of Massachusetts, Sanders’ progressive rival, finished a distant fourth in her neighboring state and, in a stinging blow to his candidacy, former Vice President Joe Biden finished fifth.

The results raised immediate questions about how much longer Biden and Warren, onetime front-runners, could afford to continue their campaigns. Both had already cut back their advertising because of financial strain.

“This victory here is the beginning of the end for Donald Trump,” Sanders told jubilant supporters in Manchester, claiming “a great victory” even before the final results were in. And looking toward Nevada and South Carolina, the next two states to vote, he vowed he would “win those states, as well.”

The rise of Sanders, a democratic socialist from Vermont who remains a political independent, has distressed many centrists and traditional liberals at a time when Democratic voters are united by a ravenous desire to defeat President Donald Trump. With Trump acting triumphant after his acquittal of impeachment charges, and with the chaotic vote-counting in Iowa and fractured field making Democrats anxious, many in the party are worried that they are endangering their opportunity to win back the White House.

Yet for Sanders, 78, winning here and cementing his status as a front-runner represented a moment of redemption just four months after he had a heart attack that threatened his candidacy, and four years after he lost the Democratic nomination after a long and often bitter primary race.

While he has not demonstrated a capacity to expand his appeal to moderate Democrats, Sanders is benefiting from something he lacked in 2016: a field of opponents who are dividing moderate voters. The centrist candidates, so far, have been unable to consolidate support.

Buttigieg and Klobuchar asserted themselves Tuesday, and their rivalry may only intensify; Biden is fading but staying in the race; and the self-funding Michael R. Bloomberg, the former mayor of New York City, is gaining strength in advance of the Super Tuesday contests next month.

As he did in Iowa, Buttigieg gave a triumphant speech that cast himself as a victor, though Sanders was still ahead by about 4,000 votes when Buttigieg took the stage. He used the moment to claim vindication from the most persistent attack leveled against him over the past week, chiefly by Biden and Klobuchar: that he lacked the résumé to be president.

New Hampshire voters, Buttigieg said, had concluded “a middle-class mayor and a veteran from the industrial Midwest was the right choice to take on this president, not in spite of that experience, but because of it.”

Without naming Sanders, he urged voters to reject a political approach that demanded revolution or nothing. Buttigieg also subtly underscored the generational gulf between him and Sanders, which could become a major theme of their rivalry. “I admired Mr. Sanders when I was a high school student,” Buttigieg said. “I respect him greatly to this day.”

Addressing supporters in Concord, New Hampshire, long before the race was called, Klobuchar opened with a salutation that nodded to her relatively unknown status with most voters: “Hello, America,” she said. “I’m Amy Klobuchar and I will beat Donald Trump.”

And she seized the moment to make the case for her own electability that doubled as a plea for political moderation. “Donald Trump’s worst nightmare,” Klobuchar said, “is that the people in the middle, the people that have had enough of the name-calling and the mudslinging, have someone to vote for in November.”

Helping Sanders just as much is the decline of Warren, whose setback in New Hampshire may allow Sanders to further coalesce the party’s left-wing voters.

Taking the stage before even half the votes were counted, but with her dismal finish clear, Warren sought to cast herself as a candidate who could unify the party’s factions and warned against a “long bitter rehash” of the center-vs.-left tensions that plagued Democrats in 2016.

“Harsh tactics might work if you’re willing to burn down the party, in order to be the last man standing,” she said.

The night was even more damaging to Biden, who was already reeling from his fourth-place finish in Iowa. Anticipating a poor showing, Biden left New Hampshire on Tuesday and headed to South Carolina, a state he hopes can salvage his candidacy.

Trying to change the subject as Warren did, Biden appeared at a rally in Columbia, South Carolina, replete with a gospel choir, and sought to contrast the heavily white electorates in Iowa and New Hampshire with those of the more diverse Nevada and South Carolina, the next states to vote.

“We haven’t heard from the most committed constituency of the Democratic Party, the African American community, and the fastest-growing segment of society, the Latino community,” he said.

But there are signs that some black voters are exploring other options, most of all Bloomberg and Tom Steyer, another self-funding billionaire who has focused much of his effort on South Carolina.

Another factor weighs heavily in Sanders’ favor: money. Besides Steyer, Sanders is the only candidate who has raised enough money to finance a robust advertising and get-out-the-vote effort in Nevada and South Carolina, which vote this month, as well as in the 15 states and territories that all vote on March 3.

His campaign announced it had raised $25 million in January, and even before polls closed Tuesday said it had already received 600,000 contributions in the first nine days of February.

In a number of the important March primary states, including California, early and mail-in voting will have been underway for weeks by the time Super Tuesday arrives, potentially giving a head start to any candidate who is ahead of the pack in the middle of February and disadvantaging those Democrats counting on a late-breaking shift in their direction.

As promising as this moment may appear, Sanders still faces daunting obstacles. Most notably, he has not yet demonstrated an ability to build a broader coalition beyond his loyal faction of progressives.

His vote total in New Hampshire was less than half of what he drew here in 2016, and he received only slightly more than a quarter of the vote in Iowa. Even if his center-left opponents continue to split voters, they still may deny him the delegate majority he needs to claim the nomination because Democrats do not have winner-take-all contests.

Each of Sanders’ top New Hampshire rivals insisted Tuesday that they were forging ahead.