The vast majority of Senate Republicans backed Majority Leader Mitch McConnell on Thursday in a rebuke of President Trump’s rationale for withdrawing U.S. troops from Syria and Afghanistan, voting to declare that the Islamic State’s presence and activity in both countries continue to pose a serious threat to the United States.

The measure, presented as an amendment to a greater Middle East policy bill, is a striking reprimand of the president from a GOP that has become increasingly comfortable expressing its opposition to Trump’s foreign policy through votes on the Senate floor.

That it was spearheaded by McConnell (R-Ky.), who often waits to cross Trump until there is overwhelming momentum in his conference, indicates how deeply the president’s announcements broke faith within the party. Republicans spent years accusing Trump’s predecessor, Barack Obama, of pursuing capricious troop withdrawals and have refused to defend Trump’s efforts to do the same.

“I believe the threats remain. ISIS and al-Qaeda have yet to be defeated, and American national security interests require continued commitment to our mission there,” McConnell said Thursday, before the 68-to-23 vote.

However, the measure divided Senate Democrats, with many arguing that rebuking Trump was not worth the cost of greenlighting endless war.

“This amendment is not the right way for us to proceed as a means of correcting Trump’s backward policies,” Sen. Chris Murphy (D-Conn.) said. “It could, frankly, get us even more deeply mired into a series of conflicts in the Middle East.”

Nearly every Senate Democrat expected to run for president in 2020 voted against the amendment.

In December, the president announced he would be withdrawing American military personnel from Syria, stating in a Twitter post: “We have defeated ISIS in Syria, my only reason for being there during the Trump presidency.” A month later, the Islamic State claimed credit for an attack in Syria that left four Americans dead.

The backlash from Republicans has been steady, with some of the president’s closest allies warning him about the dangers of leaving before al-Qaeda, the Islamic State and their affiliates are expunged. Talk of an impulsive pullout from Syria has incited fears of an ISIS resurgence there, as well as growing concern for the safety of Kurdish fighters who have partnered with U.S. forces. Some lawmakers have warned that the vacuum caused by a U.S. departure is likely to be filled by forces aligned with Iran, posing a threat to ally Israel.

Thursday’s vote comes as U.S. negotiations with the Taliban have raised the prospect of an eventual withdrawal, too, from Afghanistan, where U.S. forces have been deployed for more than 17 years.

McConnell’s amendment specifically names al-Qaeda and the Islamic State as “a global threat, which merits increased international contributions to the counterterrorism, diplomatic and stabilization efforts underway in Syria and Afghanistan.” It salutes “the positive role” the United States and its allies have played in Syria and Afghanistan, “fighting terrorist groups, countering Iranian aggression, deterring the further use of chemical weapons, and protecting human rights.”

Critically, it also warns that “withdrawal of the United States forces from the ongoing fight against these groups . . . could allow terrorists to regroup, destabilize critical regions, and create vacuums that could be filled by Iran or Russia, to the detriment of United States’ interests and those of our allies.”

Some Republicans stressed that the fringe benefit to Iran is why Trump was wrong to believe that the conflicts in Syria and Afghanistan are problems for “other people.”

“This is not other people’s wars. This is ours. These people, who are going to operate in these safe havens and Iran, we are their target,” said Sen. Marco Rubio (R-Fla.). “If you give them any belief that they have a chance to win because you have withdrawn . . . I believe you increase the chance of war.”

While the Senate’s Thursday vote does not carry the weight of law or prevent the president from pursuing his plans, it puts Senate Republicans on the record as being firmly at odds with Trump’s Middle East policy. In recent months, Senate Republicans also have backed bipartisan measures expressing support for NATO in the face of Trump’s criticisms and threats to withdraw from the alliance, and to hold Saudi Arabia’s crown prince responsible for the death of Saudi journalist Jamal Khashoggi, despite Trump having accepted the royal family’s denials.

In late January, the House overwhelmingly passed a measure to prevent Trump from using federal funds to execute a withdrawal from NATO.

Typically, such measures to counter Trump’s international moves have gotten almost unanimous support from Senate Democrats. But many saw a potential Trojan horse in the language of McConnell’s amendment, arguing that Trump’s more hawkish advisers might see a measure seeking a commitment to hostilities in Syria and Afghanistan as permission to fight wars they believe Congress never authorized.

The amendment asks the administration to show lawmakers that “conditions have been met for the enduring defeat of al-Qaeda and ISIS” before starting any troop withdrawals — a definition that struck about half the Democratic caucus as too nebulous and far-reaching to support. Some worried it might prevent Congress from putting any limits at all on the president’s war powers.

“That’s an abdication of our role to authorize the use of military force,” said Sen. Brian Schatz (D-Hawaii), one of many senators angling for Congress to debate and pass a new authorization to replace the 2001 measure under which the United States invaded Afghanistan.

The authorization, written to approve hostilities against parties responsible for the Sept. 11, 2001, terrorist attacks, has been interpreted since as a basis for fighting al-Qaeda and the Islamic State — an interpretation many believe to be flawed. Lawmakers have debated the outlines of a new military authorization specifically focused on al-Qaeda, the Islamic State and related groups — but have failed to come up with a satisfactory compromise.

Yet several leading advocates for a new authorization still supported McConnell’s amendment Thursday.

“Nothing in the McConnell amendment can be construed as an authorization for the use of military force,” said Sen. Robert Menendez (N.J.), the ranking Democrat on the Foreign Relations Committee, who backed the measure as “an important message” for Trump. “We are not in the business of authorizing open-ended conflicts or keeping our troops on the battlefields forever.”