WASHINGTON — Representative Nancy Pelosi of California, the highest-ranking House Democrat, declared on Wednesday that she was confident that her newly ascendant colleagues would elect her speaker, as she moved aggressively to hold off a challenge to her leadership that could fracture the party.

The day after midterm elections that handed her party control of the House, Ms. Pelosi curtly brushed aside questions about whether she was convinced she would continue to lead her caucus — “Yes, I am,” she said — even as other Democrats jockeyed for position. Republicans, after stinging losses, braced for a leadership battle of their own.

The maneuverings were the first signs of potentially bruising battles over the direction of both parties in a new era of divided government, in which Democrats and Republicans will both face internal struggles to define their messages and their tactics. Democrats faced immediate decisions on how aggressively, and where, to use their oversight powers to investigate President Trump and his administration, and how far to go in seeking compromise or confrontation with a commander in chief who has labeled them sworn enemies.

Mr. Trump began the day offering Ms. Pelosi an early, if unusual, endorsement on Twitter. In a backhanded compliment to an adversary he relishes attacking, he later said during a formal postelection news conference that he would even supply her with Republican votes to win the speakership if there was not sufficient support among Democrats to elect her.