Meanwhile, some Democrats are watching with a skeptical eye.

“I hope and pray that Pelosi and Schumer are more sophisticated and smarter than everyone else that’s been duped by Donald Trump,” said Representative Luis V. Gutiérrez, Democrat of Illinois, after the Democratic leaders announced their tentative deal with Mr. Trump to pursue legislation allowing the young immigrants known as Dreamers to stay in the United States.

Others see cause for optimism. Several Democratic senators, including Heidi Heitkamp of North Dakota and Richard Blumenthal of Connecticut, said they could foresee Ms. Pelosi and Mr. Schumer reaching an agreement with Mr. Trump on legislation to repair the nation’s crumbling infrastructure, an interest of all three of them.

Senator Richard J. Durbin of Illinois, the No. 2 Democrat in the Senate, went one step further, suggesting possible bipartisan cooperation on the budget.

“I think it’s encouraging; some people don’t,” Mr. Durbin said. “But look what we achieved with the first level of agreement. Without delay, without debate, without histrionics, we sent Hurricane Harvey relief out, we didn’t close down the government, and we extended the debt ceiling of the United States on a bipartisan basis. Pretty good work.”

In working with a president so despised by Democratic voters, especially those on the far left, the two Democrats must tread carefully. Ms. Pelosi got a taste of that this week in San Francisco, when she was shouted down by protesters during a news conference where she had intended to talk about the Dream Act, legislation to offer legal status and a path to citizenship for young unauthorized immigrants brought to the United States as children.

But some Democratic strategists say the leaders have little to lose.

“I think they are in position to make deals that are good for Democratic priorities and that have the support of the Democratic caucus,” said Geoff Garin, Mr. Schumer’s pollster. “And if the deals don’t do those things, then it’s easy for them to walk away.”

Ms. Pelosi and Mr. Schumer were both traveling with their families on separate vacations in Italy this summer when, each said, they began to strategize on how to use a looming fight over the debt ceiling as leverage to negotiate with Mr. Trump. Mr. Schumer said he proposed urging the White House to extend the debt ceiling for three months, which would force a vote again in December, giving the Democrats leverage over other agenda items. Ms. Pelosi, he said, quickly agreed.