WASHINGTON — Political tremors seized both major parties Thursday in the wake of President Trump’s sudden alignment with congressional Democrats, leaving Republicans alarmed about their unraveling relationship with the White House and uncertain about the prospects for their policy ambitions this fall.

In the span of 48 hours, Trump cut a deal with Democrats to keep the government funded and raise the nation’s borrowing authority, advanced talks with the senior Senate Democrat on a permanent debt ceiling solution and followed the advice of the top House Democrat, who urged him to use Twitter to ease the fears of young undocumented immigrants.

The developments confounded congressional Republicans and shook the Capitol, where some long-standing political norms seemed to many to be shattered. The upheaval raised new questions about how Trump plans to approach the looming debates over tax reform, immigration, government funding and the nation’s debt – and where Capitol Hill Republicans fit in.

“Haven’t seen anything like it before,” said Sen. John McCain, R-Ariz., who has served in the Senate for three decades. Of Trump, McCain said: “I have no way of divining his motives. I’m a pretty intelligent guy, but I don’t understand this.”

Democrats proceeded carefully amid the escalating Republican tensions, framing Trump’s overtures as an opening to assert themselves more forcefully while acknowledging that Trump’s favor could be fleeting – and that their many intractable differences are likely to remain.

“There aren’t permanent alliances. There aren’t governing philosophies. There’s day by day, seat-of-the-pants management,” Sen. Chris Murphy, D-Conn., said in an interview.

By that measure, the Democrats have enjoyed two good days working with Trump.

On Wednesday, the president agreed to support legislation providing hurricane relief money in a package that also averts an imminent shutdown of the federal government and raises its borrowing limit for three months. The deal gives Democrats leverage to play a role in negotiations over several big-ticket items at the end of the year, including efforts to pass a law allowing undocumented immigrants brought to this country as children to remain here legally.

And on Thursday, Trump talked up the possibility of permanently removing the requirement that Congress repeatedly raise the nation’s borrowing limit. It was an idea he had discussed with Senate Minority Leader Charles Schumer, D-N.Y., a day earlier, according to three people familiar with the discussion. The idea is opposed by many Republicans, including House Speaker Paul Ryan, R-Wis., who see the imposition of a debt limit as a check on government spending.

Also Thursday, Trump tweeted that young undocumented immigrants currently protected by an Obama-era executive order known as Deferred Action for Childhood Arrivals do not need to worry about his administration acting against them for the next six months. The tweet followed the White House saying this week that the program will be rescinded in six months.

It also followed a request from House Minority Leader Nancy Pelosi, D-Calif., – and was a striking move from Trump, who has largely ignored counsel of his own party’s leaders when it comes to his controversial social media habits, and who has rarely if ever communicated with Democrats about messaging.

“For all of those (DACA) that are concerned about your status during the 6 month period, you have nothing to worry about – No action!” the president tweeted from his personal account.

At a subsequent news conference, Pelosi said: “This is what I asked the president to do and, boom boom boom, the tweet appeared.”

The comity between the White House and Democrats sparked easy passage Thursday of a Hurricane Harvey relief package that allocates $15.25 billion in disaster aid and also raises the debt ceiling and keeps government open until Dec. 8. The Senate approved the measure 80 to 17 as part the pact between Trump, Schumer and Pelosi, sending it back to the House for final approval.

Democrats see the dynamics in Washington as newly fluid and potentially in their favor on a host of issues. In addition to pressing for new protections for undocumented immigrants, Democrats hope to water down Republican plans for tax policy and thwart a bevy of federal budget cuts proposed by Republicans.

Even so, some suggested caution about Trump’s sudden cooperation with them. They warned that the president’s unpredictability makes him a dangerous ally.

“Take advantage of it – but do it with the full knowledge that Trump will be calling, you know, Charles E. Schumer names on Twitter within the fortnight,” Murphy said.

Interviews with multiple Republican senators and aides Thursday, meanwhile, revealed that a sense of helplessness has gripped Republicans in the upper chamber after Trump openly flouted their plans.

“It’s just been jarring,” said one Republican Senate aide. The aide said that at the start of the week, there was a sense of confidence that White House officials were on the same page as Capitol Hill Republicans on the debt ceiling and Harvey aid negotiations. But Trump ignored the guidance of those conversations.