By ERICA WERNER

WASHINGTON — President Donald Trump overruled congressional Republicans and his own treasury secretary Wednesday and cut a deal with Democrats to fund the government and raise the federal borrowing limit for three months, all part of an agreement to speed money to Harvey relief.

In the course of a relatively brief negotiating session at the White House, Trump largely sided with Democratic leaders as they pushed for the three-month deal. He brushed aside calls from Republican congressional leaders and Treasury Secretary Steven Mnuchin for a longer extension to the debt limit, which Republicans had been aiming for to avoid having to take another vote on the politically toxic issue before the 2018 elections.

Trump then boarded a plane to North Dakota with Democratic Sen. Heidi Heitkamp, in an effort to garner bipartisan support for tax legislation that Republican leaders are crafting on a purely partisan basis.

That continued the day of bizarre disconnects between the president and the leaders of his party.

“We had a very good meeting with Nancy Pelosi and Chuck Schumer,” Trump told reporters on Air Force One, not bothering to mention House Speaker Paul Ryan or Senate Majority Leader Mitch McConnell, who also were present. “We agreed to a three-month extension on debt ceiling, which they consider to be sacred, very important.”

“We had a very good meeting, we essentially came to a deal and I think the deal will be very good,” Trump said. Details of the meeting were disclosed by several aides briefed on the proceedings who spoke on condition of anonymity because they were not authorized to talk publicly.

The deal promises to speed the $7.9 billion Hurricane Harvey aid bill, which passed the House overwhelmingly Wednesday, to Trump’s desk before disaster accounts run out later this week.

The move also buys almost three months, until Dec. 15, for Washington to try to solve myriad other issues, including more funding for the military, immigration and health care, and a longer-term increase in the government’s borrowing authority to avoid a first-ever default.

Trump cut the deal at the White House just hours after Ryan had slammed the idea of the three-month extension sought by Democrats as “ridiculous.”