The Senate passed a resolution Thursday to limit President Trump’s power to order military action against Iran without first seeking Congress’s permission, a bipartisan rebuke of his administration’s resistance to involving the legislative branch in decisions that some fear could lead to all-out war.

Eight Republicans joined all Democrats in voting 55 to 45 for the measure, despite sharp warnings from Trump that challenging his war powers would “show weakness” and send “a very bad signal” to Tehran. Trump will almost certainly veto the measure once it passes the House, and neither chamber of Congress has the votes to override that veto, lawmakers say.

Democrats behind the resolution say they are convinced the measure may yet influence Trump’s future decisions on the Middle East.

“We’ve been talking to our constituents, we’ve been listening to them, and we know what they think about another war in the Middle East right now,” said Sen. Tim Kaine (D-Va.). “[Trump’s] got an election that he’s focused on and he wants to win. . . . He could well veto it and then adjust behavior.”

Half the Senate Republicans who broke ranks with Trump had done so before on the same issue. In June, Sens. Susan Collins (R-Maine), Mike Lee (R-Utah), Rand Paul (R-Ky.) and Jerry Moran (R-Kan.) joined Democrats in backing an amendment to the annual defense bill requiring that Trump approach Congress before taking military action against Iran, except in cases of clear self-defense or imminent attack.

In March 2019, those four Republican senators, along with Sens. Lisa Murkowski (R-Alaska) and Todd C. Young (R-Ind.), joined Democrats to back a war-powers resolution ordering the president to stop helping the Saudi-led military campaign in Yemen.

The number of GOP senators willing to cross Trump over his Iran policy has risen in the wake of the strike last month that killed top Iranian military commander Qasem Soleimani, amid the possibility that it could have triggered a wider war without any congressional involvement.

Sens. Lamar Alexander (R-Tenn.) and Bill Cassidy (R-La.), who have voted with Trump on previous Iran and war-powers measures, joined the group of Republicans breaking with the president Thursday, stating that there are limits to how much the president can do without first consulting Congress.

For some of those Republicans, the vote was not a criticism of the Soleimani strike but an assertion of the need for congressional authorization before the administration embarks on a conflict.

“If this resolution was in effect at the beginning of the year, President Trump would have still been able to carry out strikes against Iran and General Soleimani (which I supported),” Cassidy said in a statement explaining his vote. “The founders gave Congress the power to declare war under Article 1 of the Constitution; we should fulfill this responsibility.”

Sen. James E. Risch (R-Idaho) argued against the resolution, saying that Congress’s time would be better spent passing a resolution cheering Trump, as it did for President Barack Obama for ordering the operation that led to the death of Osama bin Laden — who, Risch argued, posed a much less imminent threat to the country than Soleimani did.

Presidents of both parties, including George W. Bush, Obama and Trump, have said they have the right to order military action as a matter of self-defense when they see threats they define as “imminent.” But some lawmakers say the executive branch has expanded its war powers to the detriment of Congress, particularly when it invokes congressional authorizations passed in 2001 and 2002 to support action in conflicts never envisioned at that time.

National security adviser Robert C. O’Brien said the strike on Soleimani was justified by Congress’s 2002 authorization of the war on Iraq.

Efforts in Congress to repeal the old authorizations or write new ones have failed, amid the divide between lawmakers who want to bring troops home and those who want to provide fresh authorization for current campaigns.

The debate over Iran has also been fueled by many lawmakers’ frustration at what they see as a lack of candor from administration officials about what prompted the strike on Soleimani. Officials have offered shifting explanations of the basis for the strike, including that Soleimani posed an imminent threat to U.S. personnel in the Middle East and that it was retaliation for an attack on a U.S. base in Iraq that killed a U.S. contractor.

Lee, one of the Republican senators who openly criticized the administration for its mixed and limited messages, insisted this week that voting to reassert Congress’s war powers “should not be controversial” and that reclaiming such ground from the executive branch “doesn’t show weakness, that shows strength.”

It is not clear that the bipartisan nature of the vote in the House will be as strong as it was in the Senate. The House must take up Kaine’s resolution before it can be sent to Trump’s desk — something House Speaker Nancy Pelosi (D-Calif.) promised Thursday to do “in the coming weeks.”

Last month, the House passed a similar but nonbinding Iran war-powers resolution by a vote of 224 to 194. Only three Republicans joined most of the Democrats to support that measure — far fewer than joined Democrats in 2019 to back measures preventing Trump from using federal funds to conduct operations against Iran and invoking Congress’s war powers to pull back support for the Saudi-led campaign in Yemen.

One of those Republicans, Rep. Matt Gaetz (R-Fla.), is a close ally of Trump’s and a leading voice in his party for reasserting Congress’s war powers and ending endless wars. In the wake of the House’s vote last month, he told Politico that he suspected he had been kept off the president’s team of defenders during his impeachment trial as retaliation for his vote to constrain Trump’s actions against Iran.

The vote in the Senate came barely a week after Trump was acquitted of the impeachment charges against him. The Senate’s singular focus on that trial for several weeks had kept the chamber from considering the war-powers resolution that passed Thursday.