Washington – Sen. Shelley Moore Capito, R-W.Va., spent the last two weeks hammering out a deal on federal spending and border security with colleagues from both parties, reassured by a sense that Congress was finally asserting itself as a civil, stabilizing force.

The feeling did not last. On Friday, President Donald Trump mounted one of the most serious executive branch challenges to congressional authority in decades, circumventing Congress with an emergency declaration. It would allow him to unilaterally divert billions of dollars to a border wall and presented his Republican allies on Capitol Hill, who labored on a legislative compromise, with the excruciating choice of either defending their institution or bowing to his whims.

The president’s move left Senate Republicans sharply divided, and it remains to be seen whether they will act collectively to try to stop Trump or how far into uncharted territory they are willing to follow a headstrong president operating with no road map beyond his own demands.

“With him you always have to expect the unexpected,” said Capito, speaking on the phone from her kitchen in Charleston, W.Va., exhausted from a week of late-night talks at the Capitol.

The Republican resistance to Trump’s emergency declaration was much more pronounced in the Senate than in the House, where a few Republicans — in the minority but more closely aligned to Trump — groused. But most of the conservative rank and file embraced it.

After threatening to kill the spending compromise needed to keep the government open, Trump opted to cite a national emergency to pry loose additional funding to build a wall longer than the 55 miles in the bipartisan agreement. It was the divisive step that Sen. Mitch McConnell, R-Ky., the majority leader, Capito and most other Republicans in the Senate had forcefully urged him not to take, because it would establish a precedent they feared future Democratic presidents would use against them.

The decision left McConnell, a professed guardian of the Senate’s prerogatives and power, joining with Trump in supporting an executive branch end run greater than any of the incursions into the legislative process he often accused President Barack Obama of pursuing. Fellow senators said McConnell, a former member of the Appropriations Committee, was unhappy with the declaration, but saw it as the only way to pass the spending bill.

Some top Republicans, led by McConnell, pivoted quickly to say they supported the president’s action because it was the only option left to him after Congress failed to meet his demands for wall funding. McConnell has even begun offering the president strategic advice on how best to push his plan, aides said.

But McConnell is also warning Trump of the damage it could inflict on the party heading into the 2020 elections. Other Republicans portrayed it as a gross violation of the constitutional separation of powers, a blatant disregard by the president for Congress’ fundamental role in determining how federal dollars are spent.

“He is usurping congressional authority,” Sen. Susan Collins, R-Maine, a veteran member of the Appropriations Committee, said in an interview. “If the president can reallocate for his purposes billions of dollars in federal funding that Congress has approved for specific purposes and have been signed into law, that has the potential to render the appropriations process meaningless.”

Several other Senate Republicans publicly and privately joined Collins in describing the move as a flagrant breach of congressional jurisdiction and a dangerous precedent. Their numbers raised the clear possibility that enough Republican defectors could join with Senate Democrats to provide a majority to disapprove of the president’s decision should the opportunity arise.

Four Republicans might be enough to join with Senate Democrats and pass legislation rebuking the president, and leadership aides put the number of potential defectors as high as 10. But the unrest seemed well short of the sort of partywide revolt necessary to override a veto by Trump of any legislative attempt to prevent his declaration of an emergency, leaving a legal challenge as the only recourse.

“I would not vote for disapproval,” said Sen. Richard Shelby, R-Ala., the Appropriations Committee chairman who led the spending negotiations. “He’s got the power to defend the country, to defend the borders, to protect the people as commander-in-chief. I believe the courts would uphold him on this.”

Despite reservations about many of the actions taken by Trump and the White House over the past two years, most congressional Republicans have been reluctant to put too much distance between themselves and the president given his grip on Republican voters, many of whom consider the wall a national necessity. Trump exerts a powerful hold on his party, and lawmakers are cowed by the belief that opposing him will end in their political destruction.

Still, the emergency declaration was a direct assault on the ability of lawmakers themselves to restrain the president, and it raised expectations that more could balk at what was widely viewed as a serious case of executive overreach.

“Somebody is going to have to say enough is enough,” said Trent Lott, the former Senate leader from Mississippi.

Even those senators who said they were willing to abide by the president’s decision did so grudgingly, acknowledging that it was a bad way to govern and could have significant consequences.

“I don’t see anything that necessarily violates the law, but that is a very different question from whether we should be doing it,” said Sen. Mike Lee, R-Utah, a conservative known for his view that Congress has handed over too much power to the executive branch.

Democrats were united in their condemnation, accusing Trump of claiming a false crisis because he could not win over Congress with his argument. They said the president was so desperate to build the wall as a difficult re-election campaign loomed that he was willing to shred the Constitution to do so.