WASHINGTON — Republican congressional leaders perched on the couches in the Oval Office froze in mid-smile on Wednesday afternoon when they realized President Trump was bypassing them to cut a short-term spending and debt ceiling deal with Democrats, and not them.

Speaker Paul D. Ryan and Senator Mitch McConnell, the majority leader, had expected the rare bipartisan, bicameral meeting to be little more than a photo-op in which the broad outlines of a deal were discussed, aides said.

Instead, Mr. Trump — who has often outsourced the details of negotiations to subordinates like Vice President Mike Pence — interrupted Treasury Secretary Steven Mnuchin as he argued for an 18-month debt ceiling increase to stabilize financial markets. When other leaders offered yearlong or half-year extensions, the president waved them off, according to the accounts of staff members briefed on the meeting.

The three-month deal Mr. Trump eventually embraced is a significant tactical change for a president thus far anxious to preserve, not expand, his political appeal. The plan was pitched by two Democratic leaders he has relentlessly demonized and marginalized: Senator Chuck Schumer of New York and Representative Nancy Pelosi of California.