Mr. Sanders, a democratic socialist making his second run for the White House, withdrew after a series of losses to Joseph R. Biden Jr., who emerges as the presumptive nominee for the general election.

Senator Bernie Sanders of Vermont dropped out of the Democratic presidential race on Wednesday, concluding a quest for the White House that began five years ago in relative obscurity but ultimately elevated him as a champion of the working class, a standard-bearer of American liberalism and the leader of a self-styled political revolution.

Mr. Sanders’s exit from the race establishes former Vice President Joseph R. Biden Jr. as the presumptive nominee to challenge President Trump, and leaves the progressive movement without a prominent voice in the 2020 race.

“I cannot in good conscience continue to mount a campaign that cannot win and which would interfere with the important work required of all of us in this difficult hour,” Mr. Sanders said over a live stream Wednesday morning.

He said that he would remain on the ballot in states that still have primaries scheduled and would continue to gather delegates, as a way of carrying his message forward and influencing the Democratic platform.

“While this campaign is coming to an end, our movement is not,” he said.

In a race reshaped, and eclipsed, by the escalating coronavirus crisis, Mr. Sanders faced no realistic path to the nomination after a series of lopsided losses to Mr. Biden, beginning in South Carolina in late February and culminating with a string of losses last month in crucial states like Michigan and Florida.

With the public health emergency preventing both candidates from holding in-person campaign events, Mr. Sanders spent the last several weeks on the sidelines, delivering addresses via live stream and making occasional television appearances, while facing calls from fellow Democrats to exit the race and help unify the party behind Mr. Biden. Though Mr. Biden had been careful not to pressure Mr. Sanders, he had begun to move ahead as if the race were over, taking steps, for example, to begin his search for a running mate.

As Mr. Sanders pursued the White House for a second time, he promised that he could transform the electorate, bringing new voters under the Democratic tent, but that goal eluded him. Even Mr. Sanders has lamented that he was unable to produce a surge in young voters.

In early primaries this year, he also failed to show that he had remedied a crucial weakness from his 2016 run: a lack of support from black voters, a vital base of the Democratic Party. In state after state across the South — Alabama, the Carolinas, Mississippi, Virginia — he was unable to chip away at Mr. Biden’s strong support among African-Americans.

In many ways, Mr. Sanders never overcame the widely held view among Democrats that he was a political outlier, a self-described democratic socialist who proudly proclaimed himself to be an independent senator from Vermont rather than a member of the party establishment.

Mr. Sanders championed and popularized liberal policies like “Medicare for all” and free four-year public colleges aimed at lifting up America’s working class, but he faced opposition from many party leaders, elected officials and major donors, as well as large numbers of moderate voters who saw him as too far left.

Mr. Sanders never accepted that argument. In recent weeks he said repeatedly that he had won the ideological debate, asserting that a strong majority of Democrats supported his progressive agenda. But during a striking news conference in Burlington, Vt., last month, he also acknowledged that he was losing the electability battle to Mr. Biden, saying voters had made clear that they thought the former vice president was the best candidate to beat Mr. Trump.

He repeated that argument in his announcement on Wednesday.

“Focusing on that new vision for America is what our campaign has been about and what in fact we have accomplished,’’ he said. “Few would deny that over the course of the past five years our movement has won the ideological struggle.”

His departure from the race is a striking turnaround for a candidate who less than two months ago was the clear front-runner, after finishing in a tie for first in Iowa and winning in New Hampshire and Nevada. And for a man who is loath to admit defeat, it is a concession that he saw no path to overcoming Mr. Biden, and that he may have more leverage for his liberal policy agenda if he ceded the race and joined forces with his rival.

His exit is also a sharp contrast to his bid in 2016, when he stayed in an increasingly acrimonious race against Hillary Clinton even after it became clear she would be the eventual nominee.

For months, Mr. Sanders had vowed to do everything he could to beat Mr. Trump in November, and his departure, though not what he had envisioned, amounted to an acknowledgment that continuing to battle against Mr. Biden would preclude the kind of party unity necessary for the general election fight ahead. Mr. Sanders has repeatedly said he would support the former vice president if he were the nominee.

Mr. Sanders inspired the modern progressive movement and electrified a legion of loyal supporters.

Mr. Sanders, 78, leaves the campaign having almost single-handedly moved the Democratic Party to the left. He inspired the modern progressive movement with his expansive policy agenda and his impassioned message that “health care is a human right,” and electrified a legion of loyal supporters who wholeheartedly embraced his promise to lift up those who need it most. He also transformed the way Democratic campaigns raised money, eschewing big fund-raisers and instead relying on an army of small-dollar donors.

But Mr. Sanders stirred deep unease among party leaders, and as he ascended to the top of the field in February, establishment Democrats scrambled to block his path, convinced his far-reaching proposals would alienate great swaths of the electorate and make him an easy target for Mr. Trump.

Moderate candidates in the race who could not overcome Mr. Biden dropped out and endorsed the former vice president just before Super Tuesday, on March 3, helping him sweep 10 of 14 states on the biggest voting day of the primary. That led to a wave of new endorsements and a remarkable coalescing around Mr. Biden that Mr. Sanders could not match on the left.

And while Mr. Sanders burst onto the political scene in 2015 as an insurgent populist, he no longer benefited from being the only alternative to an establishment he loathed. He also faced a formidable rival in Mr. Biden, who was competing for white working-class voters, a critical slice of Mr. Sanders’s constituency.

Even before Mr. Sanders announced in February 2019 that he was running again, there were indications his campaign would not be smooth. His media consulting team abruptly quit after clashing with him and his wife, Jane, over an announcement ad. Through the spring, he largely stuck to his familiar message, battling establishment forces rather than his immediate rivals. Amid a slump in the polls in the fall, he suffered a heart attack while campaigning in Las Vegas, a startling event that threatened to upend his bid.

The health crisis prompted even some of his allies to call for him to drop out and endorse his ideological ally, Senator Elizabeth Warren of Massachusetts.

But in a remarkable turn of events — as he stood on the debate stage just two weeks after his heart attack — he received the endorsement of Representative Alexandria Ocasio-Cortez of New York, one of the most visible liberal congresswomen and a star of the left. It helped jump-start his candidacy just as it appeared in jeopardy of collapsing.

The endorsement of Representative Alexandria Ocasio-Cortez of New York jump-started Mr. Sanders’s campaign just as it appeared on the brink of collapse last year.

The endorsement helped carry him through the late fall and early winter, infusing his campaign with momentum and lifting him in polls of critical early states, including Iowa. He again began to draw enormous crowds at rallies across the country, sometimes with Ms. Ocasio-Cortez by his side.

At turns, he appeared to collide with Ms. Warren, and never more so than in January, when she accused him of telling her in a private conversation in 2018 that a woman could not win the presidency. Mr. Sanders denied he had said that, and the allegation faded from the race as he pivoted to go on offense against Mr. Biden.

For several weeks, Mr. Sanders surged. In Iowa, he finished in a virtual tie for first with Pete Buttigieg, the former mayor of South Bend, Ind., who, at 38, was less than half his age. He then narrowly beat Mr. Buttigieg in New Hampshire, before dominating the field less than two weeks later in the Nevada caucuses.

Suddenly there was talk that Mr. Sanders would run away with the nomination. But his loss in South Carolina to Mr. Biden, who had emerged as the leading moderate in the race, brought his momentum to an abrupt halt, raising significant questions about his weaknesses with black voters and an overriding failure to expand his base.

Three days later, as centrist Democrats rushed to support Mr. Biden, Mr. Sanders lost all of the Southern states voting on Super Tuesday as well as states like Massachusetts and Minnesota that he had expected to win.

Mr. Sanders quickly canceled a planned rally in Mississippi and deployed resources to Michigan, a tacit acknowledgment that the Midwestern state had become something of a must-win for his candidacy to survive.

But it was not to be. The momentum had turned solidly to Mr. Biden, who won Michigan easily, then a week later captured three big delegate prizes — Florida, Illinois and Arizona.

By then, the coronavirus was disrupting the rest of the political calendar, forcing states to postpone their primaries until June. Mr. Sanders has spent much of the intervening time at his home in Burlington without his top advisers, assessing the future of his campaign. Some close to him had speculated he might stay in the race to continue to amass delegates as leverage against Mr. Biden.

But in the days leading up to his withdrawal from the race, aides had come to believe that it was time to end the campaign. Some of Mr. Sanders’s closest advisers began mapping out the financial and political considerations for him and what scenarios would give him the maximum amount of leverage for his policy proposals, and some concluded that it was more beneficial for him to suspend his campaign.