Then Hurricane Harvey landed, strengthening the Democratic negotiating position, because the necessary relief and recovery money for Texas and Louisiana would be a must-pass measure, and it could be combined with the debt limit proposal. Given the damage from that storm and the threat posed by others menacing the Atlantic Coast, Mr. Trump and House and Senate Republicans could hardly afford to either let the government shut down or default on its obligations.

This confluence of events — expiring government funding, the critical need to raise the debt limit, the passage of one hurricane and the approach of two others, and the availability of a workable Democratic alternative — persuaded Mr. Trump to side with the top two Democrats over the stunned leaders of his own party. Suddenly, Mr. Trump couldn’t get enough of Chuck and Nancy, his two new allies, despite his disparagement of both this year. The plan easily passed the House and the Senate, though many Republicans were disgruntled.

Whether the outbreak of bipartisanship represented a real turning point — “The president is sometimes, as you know, erratic,” Mr. Schumer said — remains to be tested. But Mr. Trump certainly put Mr. Schumer in the catbird seat for the coming talks. Republicans were so distressed that Senator Ben Sasse, Republican of Nebraska, took to the Senate floor to fume that Mr. Schumer had “just made himself the most powerful man in America for the month of December.” The comment was meant to admonish Republican leaders, but it had to be music to Mr. Schumer’s ears.

Mr. Schumer, who had hoped to be majority leader this year serving with a President Hillary Clinton, has had an up-and-down relationship with Mr. Trump. While the president has contributed to Mr. Schumer’s past campaigns, he has gone after him repeatedly this year on Twitter.

But the president has also shown an affinity for Mr. Schumer that has been denied his top Republican allies in Congress: Senator Mitch McConnell, the majority leader, and Speaker Paul D. Ryan. Perhaps it is because he and Mr. Schumer are both products of the outer boroughs, Queens and Brooklyn, respectively.

“The one thing we have is we’re New Yorkers,” Mr. Schumer said. “We’re pretty direct, and we talk right at each other.”