The vast majority of Senate Republicans on Thursday voted in favor of legislation critical of President Donald Trump's plan to pull US troops out of Syria and Afghanistan.

Republicans in Congress have been particularly critical of Trump on foreign policy in recent months, especially in relation to ISIS.

The amendment that passed on Thursday, which was drafted by Senate Majority Leader Mitch McConnell, is set to be added to a broader piece of Middle East policy legislation.

Top Republicans in the Senate are rebuking President Donald Trump's foreign policy — again.

Legislation drafted by Senate Majority Leader Mitch McConnell that criticized the president's plans to withdraw US troops from Afghanistan and Syria was overwhelmingly advanced by senators on Thursday in a 68-to-23 vote.

The vast majority of Republicans voted in favor of the measure, which warns of the consequences of the US pulling out amid ongoing threats from the Islamic State group, or ISIS, in both countries.

"The precipitous withdrawal of United States forces from either country could put at risk hard-won gains and United States national security," the legislation reads.

Read more: Inspired by Jamal Khashoggi's killing, lawmakers renew fight to defy Trump and end US support for Saudi Arabia in Yemen

The amendment is set to be added to a larger Middle East policy bill that is expected to pass in the GOP-led Senate but could face opposition the Democratic-controlled House in relation to a provision on Israel, according to The Washington Post.

Republicans have been criticizing Trump on Syria and Afghanistan since December when he abruptly announced plans to withdraw troops from the two countries, saying ISIS had been defeated in the process.

ISIS has been greatly diminished and no longer controls a large swath of territory across Iraq and Syria that provided the basis for its self-declared caliphate, but the US intelligence community and the Pentagon have repeatedly said it continues to pose a threat.

Correspondingly, Trump has sparred with his intelligence chiefs over the course of the week because of an intelligence-community report on global threats that undermined the president's foreign-policy rhetoric and claims — including his assertions about ISIS.

The new Worldwide Threat Assessment said that ISIS still has thousands of fighters in Iraq and Syria, and is continuing to plan attacks.

An ISIS-claimed attack in Syria earlier this month resulted in the deaths of four US citizens, including two US service members. This was a devastating blow to Trump's claims in late December that ISIS was defeated, an assertion that Senate Republicans again slapped down with Thursday's vote.

The US has roughly 2,000 troops in Syria and approximately 14,000 in Afghanistan. Trump in December signaled he wanted to withdraw all US troops from Syria and roughly half of those stationed in Afghanistan.

Read more: Trump's own party slams his Syria 'retreat' after ISIS-claimed attack kills US troops

Meanwhile, in a separate move that defies Trump's foreign-policy agenda, a bipartisan group of lawmakers on Wednesday renewed a push for a resolution that would end US support for the Saudi-led coalition in Yemen. Key Republicans have in recent months supported such legislation in relation to outrage over the killing of Saudi journalist Jamal Khashoggi, and this seems to have carried into 2019.