WASHINGTON — Representative Nancy Pelosi of California, the highest-ranking House Democrat, got an early, if unusual, endorsement on Wednesday in her bid to reclaim her title as speaker following Tuesday’s electoral victory: a favorable tweet from President Trump.

“In all fairness, Nancy Pelosi deserves to be chosen Speaker of the House by the Democrats,” Mr. Trump wrote in a morning Twitter post, echoing an argument that Ms. Pelosi has been making in recent weeks, and signaling that he relishes the chance to spar with her over the next two years. “If they give her a hard time, perhaps we will add some Republican votes. She has earned this great honor!”

Democrats, fresh off their successful effort to wrest control of the House from Republicans and open a new era of divided government in the Trump administration, now face a consequential set of choices about their leadership as a new, more diverse and younger majority prepares to take over.

Ms. Pelosi, 78, has exuded confidence in recent days that her colleagues would choose her to resume her tenure as the first female speaker of the House, and whispers that she would face a serious challenge appear to have dissipated amid large Democratic gains under her stewardship.

“With victory on your side, it always helps a lot,” said Representative Henry Cuellar, Democrat of Texas, who said he would back Ms. Pelosi for speaker. But he and other more centrist members of the party in the House will insist on changes to ensure they have a voice in legislating and policymaking.

Some of the Democratic candidates most outspoken about opposing her speakership lost on Tuesday, such as Richard Ojeda in West Virginia and Dan McCready in North Carolina. But others won, including Abigail Spanberger in Virginia.

Mr. Trump’s endorsement comes with an edge. Republicans have long cheered Ms. Pelosi’s continued reign over House Democrats, seeing in her the perfect foil for negative campaign ads to rile conservative voters. Ms. Pelosi again was the star of hundreds of Republican ads that blanketed the country.

In recent months, the president, who phoned Ms. Pelosi on Tuesday night to congratulate her on the Democrats’ victory, singled her out by name and savaged her during his raucous rallies.

Representative Steny H. Hoyer, Democrat of Maryland, said on Tuesday night that he planned to run for majority leader, the No. 2 position in the House, while Representative James Clyburn of South Carolina plans to run for whip, the No. 3 post. That lineup, if endorsed by Democrats, would preserve the top three positions in the party’s House caucus as they currently are — with none of the youthful sheen of the incoming class.

But members of the Congressional Black Caucus have said they want one of their own to be considered for any vacancy in the top two positions. Representative Ben Ray Luján of New Mexico, the triumphant chairman of the Democratic Congressional Campaign Committee, is expected to run for a leadership post.

That leaves the roster uncertain, opening the possibility of a power struggle for one of the top two slots.

Mr. Clyburn, who is black, said on Tuesday night that he believed Ms. Pelosi would stay in the top position, with Mr. Hoyer second in line, and “hopefully” himself third. He said he expected to see more African-Americans in other leadership positions, arguing that the newer members would accept such a result.

“I’ve been campaigning for all of these people — I talk to them all the time,” Mr. Clyburn said. “I was on the phone with a lot of them today — I’m talking about 30-something-year-olds. I don’t have any problem with them.”