WASHINGTON — Democrats took giant steps toward party unity Thursday as Bernie Sanders vowed to work together with Hillary Clinton to defeat Donald Trump in November and President Barack Obama formally endorsed Clinton for president.

Sanders’ decision to continue his White House bid even after Clinton became the party’s presumptive presidential nominee has had Democrats on high alert as they seek to quickly change gears and take on Trump, the presumptive Republican presidential nominee. Sanders’ first explicit promise on Thursday to join forces with Clinton to take on the Republicans will help quell concerns among Democrats about divisions in the party.

Emerging from the White House after a meeting with Obama that lasted more than an hour, Sanders warned that a Trump presidency would be a “disaster” and that he would “work as hard as I can to make sure that Donald Trump does not become president of the United States.”

“I look forward to meeting with (Clinton) in the near future to see how we can work together to defeat Donald Trump and to create a government which represents all of us and not just the 1%,” Sanders told reporters.

The senator thanked both Obama and Vice President Joe Biden for showing “impartiality” during the course of the Democratic campaign.

“They said in the beginning that they would not put their thumb on the scales and they kept their word and I appreciate that very, very much,” Sanders said.

He added that he will monitor a “full counting of the votes” in California, where Clinton won the Democratic primary contest on Tuesday. The results will show “a much closer vote,” Sanders predicted.

In a press briefing Thursday afternoon, White House spokesman Josh Earnest described the meeting as a “friendly conversation that was focused on the future,” and said Obama congratulated Sanders on his “remarkable accomplishment” in the Democratic race.

Shortly after the meeting, the White House released a video in which Obama enthusiastically backed Clinton and acknowledged the historic achievement of her becoming the first woman to win a major party’s presidential nomination. He will join Clinton on the campaign trail for the first time next week in Wisconsin.

“I don’t think there’s ever been someone so qualified to hold this office,” Obama said in the video of Clinton, whom he defeated eight years ago.

He also thanked Sanders in the video for running an “incredible campaign” and for shining a spotlight on issues such as economic inequality and the influence of money in politics.

Sanders’ high-profile meeting with Obama and his public remarks afterward come just days after Sanders declared that he intends to continue his 2016 campaign. At a rally Tuesday night, Sanders had declined to acknowledge that Clinton had secured the necessary delegates to win her party’s nomination. He vowed to forge ahead to the District of Columbia’s primary next week, and then on to the Democratic National Convention in Philadelphia.

The Sanders-Obama meeting Thursday marked the two men’s second White House sitdown this primary season and the fourth time they’ve spoken in the last month. White House officials hoped Obama could prod the Vermont senator toward eventually acting as a unifying figure for the Democratic Party.

In a taping of “The Tonight Show” with Jimmy Fallon on Wednesday, Obama said he was hopeful that the party will “pull things together.”

“The main role I’m going to be playing in this process is to remind the American people that this is a serious job,” Obama said. “You know, this is not reality TV. I’ve seen the decisions that have to be made and the work that has to be done.”

The whirlwind day for Sanders helped shed light on his intentions and state of mind — particularly the role he hopes to play in his party — as the general election kicks off in earnest.

Sanders sat down in the afternoon with his longtime friend and Senate Minority Leader Harry Reid, who has publicly said Sanders should “give up.” Reid described the meeting to reporters afterward as a “good visit,” and emphasized that Sanders has the good will of the Senate Democratic caucus. The Nevada senator said Sanders made no mention of changing the reality that Clinton is the party’s presumptive nominee, and quipped that Sanders appears to have “accepted that.”

Reid also echoed other Democratic leaders, saying, “I’m not pushing him to do anything.”

Prior to that meeting, one source familiar with Reid’s thinking said he believes Sanders can be helpful in Senate races, including in raising money, and is open to any number of ways to unite the party.

Sanders will also meet with Biden Thursday afternoon at the Naval Observatory, according to sources. The vice president does not plan to make any endorsements before those conversations, one aide said.

In the evening, Sanders will attend a campaign rally in Washington.

Since clinching her party’s nomination, Clinton has stuck to a conciliatory tone when it comes to her rival.

In her victory speech in Brooklyn Tuesday night, Clinton congratulated Sanders for an “extraordinary campaign” and sought to reach out to his supporters.

“Let there be no mistake: Sen. Sanders, his campaign, and the vigorous debate that we’ve had about how to raise incomes, reduce inequality, and increase upward mobility, have been very good for the Democratic Party and for America,” Clinton said.