President Trump, a man of few allegiances who seized control of the Republican Party in a hostile takeover, suddenly aligned himself with Democrats on Wednesday on a series of key fiscal issues — and even gave a lift to North Dakota's embattled Democratic U.S. senator.

Trump confounded his party's leaders when he cut a deal with Democratic congressional leaders — "Chuck and Nancy," as the president informally referred to them — on a short-term plan to fund the government and raise its borrowing limit this month.

The president's surprise stance upended sensitive negotiations over the debt ceiling and other crucial policy issues this fall and further imperiled his already tenuous relationships with Senate Majority Leader Mitch McConnell (R-Ky.) and House Speaker Paul D. Ryan (R-Wis.).

The episode is the latest turn in Trump's separation from his party as he distances himself to deflect blame for what has been a year of gridlock and missed opportunities for Republicans on Capitol Hill. It follows a summer of presidential stewing over McConnell and Ryan, both of whom Trump views as insufficiently loyal and weak in executing his agenda, according to his advisers.

Trump made his position clear at a White House meeting with both parties' congressional leaders, agreeing with Senate Minority Leader Charles E. Schumer (D-N.Y.) and House Minority Leader Nancy Pelosi (D-Calif.) on plans for a bill to fund the government and raise the debt ceiling for three months.

That effectively postpones until December a divisive fight over fiscal matters, including whether to fund construction of Trump's long-promised wall at the U.S.-Mexico border.

"We had a very good meeting with Nancy Pelosi and Chuck Schumer," Trump told reporters Wednesday aboard Air Force One as he traveled to North Dakota. "We agreed to a three-month extension on debt ceiling, which they consider to be sacred — very important — always we'll agree on debt ceiling automatically because of the importance of it."

In siding with Democrats, Trump overruled his own treasury secretary, Steven Mnuchin, who was in the middle of an explanation backing a longer-term increase when the president interrupted him and disagreed, according to a person briefed on the meeting who was not authorized to comment publicly and spoke on the condition of anonymity. Trump was "in deal-cutting mode," the person said.

[Schumer, Pelosi offer Democratic votes for Harvey aid if paired with short-term debt-limit hike]

After the gathering, McConnell said he would add provisions extending government funding and the debt limit through mid-December to legislation passed by the House on Wednesday providing $7.85 billion in Hurricane Harvey relief. McConnell introduced the legislation late Wednesday night, setting up a Senate vote as early as Friday.

"The president agreed with Senator Schumer and Congresswoman Pelosi to do a three-month [funding extension] and a debt ceiling into December, and that's what I will be offering, based on the president's decision, to the bill," McConnell told reporters. "The president can speak for himself, but his feeling was that we needed to come together to not create a picture of divisiveness at a time of genuine national crisis."

Later in the evening, McConnell introduced legislation to extend current spending levels and the federal borrowing limit until Dec. 8 and increase disaster funding to $15.25 billion. The funding boost includes several provisions to address potential damage from Hurricane Irma, which is expected to make landfall in the continental United States over the weekend.

During the meeting Wednesday, Trump also threw tacit support behind the Democrats' push for a "dreamers" bill that would effectively formalize an Obama-era program shielding undocumented immigrants brought to the United States as children from deportation.

Trump on Tuesday began phasing out the Deferred Action for Childhood Arrivals program, which GOP hard-liners regard as illegal amnesty, but suggested Wednesday that if Congress passed a dreamers bill he might sign it.

"Chuck and Nancy want to see something happen — and so do I," Trump said.

Later Wednesday, Trump brought a special guest with him to an oil refinery in Mandan, N.D., to pitch his tax-cut plan: Sen. Heidi Heitkamp, a Democrat facing a tough reelection effort in a solidly Republican state that Trump carried in 2016 by 36 percentage points. He welcomed Heitkamp into his traveling delegation, affording her the chance to appear bipartisan by standing alongside a president popular with North Dakotans.

As Heitkamp stepped onto an outdoor catwalk at the Mandan refinery to join him on stage, Trump delivered play-by-play commentary: "Everybody's saying, 'What's she doing up here?' But I'll tell you what: Good woman."

Trump opened his speech by recounting his "great bipartisan meeting" at the White House. "I'm committed to working with both parties to deliver for our wonderful, wonderful citizens," Trump said, citing Schumer and Pelosi by name before mentioning the Republicans who were in attendance.

"Everybody was happy," Trump said of the meeting. "Not too happy, because you can never be too happy, but they were happy enough."

By setting up another debt-ceiling vote in December — a vote in which Republicans will almost certainly need Democratic help to avoid default — Democrats keep their seat at the table in this fall's key policy debates.

[Trump administration announces end of immigration protection program for ‘dreamers’]

Had Trump sided with GOP leaders, Democrats would have been stuck trying to extract concessions ahead of debt-ceiling votes this week using an empty threat — voting against a legislative package that includes the politically sensitive Harvey aid. Democrats believe pushing the debt-limit debate into December will increase their leverage on several issues, including the protection of dreamers and securing funds to help stabilize health-care markets.

Schumer and Pelosi also gained an edge by giving Democrats an aura of strategic command they have lacked since Trump's election. Instead of McConnell claiming victory, it was Schumer who told reporters, "The nation can breathe a sigh of relief."

The deal may also benefit Trump by allowing him to revive his threat to shut down the government over wall funding.

At the White House, Republican leaders pushed for an 18-month debt-limit hike, then floated doing a six-month extension, according to two aides briefed on the meeting. But Pelosi and Schumer dismissed the six-month proposal, and Trump then agreed to the three-month hike that Democrats put on the table.

McConnell and Ryan came out of the White House meeting in the weakest position — losing an opportunity to neutralize the debt-ceiling issue before the 2018 midterm elections and to exclude Democrats from major policy debates this fall.

The president's decision came barely an hour after Ryan panned the idea of a short-term debt hike, accusing Democrats of "playing politics" with much-needed aid for Hurricane Harvey victims.

"I think that's ridiculous and disgraceful that they want to play politics with the debt ceiling at this moment when we have fellow citizens in need," Ryan told reporters.

Trump apparently disagreed.

"We essentially came to a deal, and I think the deal will be very good," Trump said. "We had a very, very cordial and professional meeting."

Not all Democrats were so thrilled with the deal. Some were upset it did not include protections for the estimated 800,000 dreamers.

"So Trump attacks our dreamers, and the next day the Democrats walk in there and say, 'Oh, let's just have a nice timeout,' while they're all suffering?" said Rep. Luis V. Gutiérrez (D-Ill.). "That is what is wrong with Democrats. They don't stand up."

Schumer said he was not finished advocating for dreamers. "This is not a trade-off for us," he said. "This is a very important issue that we're going to fight hard for until we get it done."

The plan for now is to suspend the debt ceiling until Dec. 15 and then revisit it with a vote by Congress before then, but the Treasury Department would retain flexibility to take emergency steps, two congressional aides said.

The short-term extensions for the debt ceiling and government funding are also expected to further cloud the prospects for enacting major tax cuts, Trump's top domestic priority. They effectively mean spending and budget fights will continue for months, just as the GOP was hoping to coalesce around a plan to cut taxes.

Trump tried to rally support for his tax plan in North Dakota.

"Anybody that's going to vote against tax cuts and tax reforms — whether it's in North Dakota or anybody else or any place else — you've got to vote against them and get them out of office, because it's so, it is so bad," Trump said, pausing so that the crowd could cheer. "This is not a close one."

The White House meeting took place just as the House approved the Harvey aid package, its first major order of business after the August recess.

The measure — providing $7.4 billion for the Federal Emergency Management Agency and $450 million for a disaster loan program for small businesses — passed 419 to 3, with 12 members not voting. Reps. Thomas Massie (R-Ky.), Justin Amash (R-Mich.) and Andy Biggs (R-Ariz.) voted no. It now moves to the Senate, where leaders plan to hold a vote by the end of the week.

[Recovering from Harvey when ‘you already live a disaster every day of your life’]

Top House Republicans barely veiled their frustration with Trump's decision to side with Democrats on the debt ceiling. House Rules Committee Chairman Pete Sessions (R-Tex.) said he "would have not tied the knot so tight" for December, saying an extension till at least February would have been better, but he carefully avoided criticizing Trump.

"We all do it differently," Sessions said. "I think it was an overly generous answer that he gave our friends the Democrats. But I'm not going to be critical of my president. I support my president."

Rep. Mark Meadows (R-N.C.), the chairman of the conservative House Freedom Caucus, was among those who warned that Democrats' short-term debt-limit request could threaten GOP efforts to cut spending.

"Obviously getting a [continuing resolution] and the debt ceiling to not come due at the same time would be the most prudent fiscal decision we could make," Meadows told reporters.

Rucker reported from Mandan. Damian Paletta, Abby Phillip, Paul Kane and Jenna Johnson in Washington contributed to this report.

Read more at PowerPost