The amendment by Senate Majority Leader Mitch McConnell comes after Trump called for a drawdown of troops in both of those countries. The measure says the Islamic State and al-Qaida militants still pose a serious threat to the United States, and it warns that "a precipitous withdrawal" of U.S. forces from those countries could "allow terrorists to regroup, destabilize critical regions and create vacuums that could be filled by Iran or Russia."
Trump abruptly tweeted plans for a U.S. pullout from Syria in December, arguing that the Islamic State had been defeated even though his intelligence chiefs have said the group remains a threat. Trump also ordered the military to develop plans to remove up to half of the 14,000 U.S. forces in Afghanistan.
McConnell didn't frame the measure as a reproach to the president, but he said before the vote that "I've been clear about my own views on these subjects." He said he believes the threats remain.
"ISIS and al-Qaida have yet to be defeated," McConnell said. "And American national security interests require continued commitment to our missions there."
The vote is the latest indication of deepening cracks between the Republican Senate and Trump on foreign policy matters. Similar rifts exist within Trump's own administration, evident this week when the heads of major U.S. intelligence agencies testified to the Senate and contradicted him on the strength of the Islamic State and several other foreign policy matters. Trump's announcement on Syria, meanwhile, prompted the resignation of Defense Secretary James Mattis.
McConnell's amendment, which is nonbinding, would encourage cooperation between the White House and Congress to develop long-term strategies in both nations, "including a thorough accounting of the risks of withdrawing too hastily."
Sen. Marco Rubio, R-Fla., argued in support of the amendment on the Senate floor, saying Trump's withdrawal announcement has already undermined U.S. credibility in the region.
"This is being used against us right now," Rubio said. "This is a very dangerous situation. That's why this is a very bad idea."
Though many Democrats have argued that the U.S. should eventually withdraw from the conflicts in Syria and Afghanistan, around half of them supported McConnell's resolution.
California Sen. Dianne Feinstein said after the vote that she believes it's "far past due for the United States to negotiate an appropriate end" to the conflict in Afghanistan. But she said she also agreed with McConnell that the "precipitous withdrawal" from either country without political resolutions would risk what troops there have already achieved. She voted in favor of the measure.
Many of the most liberal members of the Senate — including several Democrats who are eying presidential runs in 2020 — voted against the amendment.
Independent Sen. Bernie Sanders of Vermont said he thinks Trump announced the withdrawals too abruptly, but the U.S. has been in Afghanistan and Syria for too long. "What McConnell is saying is let's maintain the status quo," he said.
A handful of Republicans also opposed the amendment. McConnell's Kentucky colleague, Republican Sen. Rand Paul, missed the vote but said he was against it.
"It's time to bring our troops home from Afghanistan and Syria," Paul wrote in a tweet, saying he stands with Trump. "It is ludicrous to call withdrawal after 17 years 'precipitous.'"
A vote on final passage of the amendment could come early next week. If it succeeds, the language would be added to a wide-ranging foreign policy bill that has been pending on the Senate floor for several weeks. The legislation includes measures supporting Israel and Jordan and slapping sanctions on Syrians involved in war crimes.
That bill has also split centrist and liberal Democrats over a provision by Rubio that seeks to counter the global Boycott, Divest and Sanctions movement against Israel over its treatment of Palestinians and their settlements. Israel sees a growing threat from the BDS movement, which has led to increased boycotts of the Jewish state in support of the Palestinians.
That has led to a "boycott of the boycotts" as Israel pushes back against those aligned with BDS.
In support of Israel, Rubio's measures would affirm the legal authority of state and local governments to restrict contracts and take other actions against those "engaged in BDS conduct." Several states are facing lawsuits after taking action against workers supporting BDS boycotts of Israel.
Opponents say Rubio's measure infringes on free speech.