The Senate voted nearly unanimously on Wednesday to allow Congress to strip the president of the power to unilaterally lift existing sanctions against Russia, a matter that had many of President Trump’s allies siding with his harshest critics.

The measure, which was approved 97 to 2 — Senators Rand Paul of Kentucky and Mike Lee of Utah, both Republicans, were the only votes against it — bolsters existing sanctions and would allow Congress to thwart any presidential effort to curtail sanctions without congressional approval.

Senator Bob Corker, Republican of Tennessee, said the overwhelming passage of the measure “sends a strong signal to President Putin while ensuring the Trump administration has the flexibility it needs.”

“The Russian government continues to violate the sovereignty of Ukraine, aggravate the crisis in Syria and destabilize democracies around the world,” he added. “This amendment makes clear that we will not continue to tolerate such actions.”

During the hearing on Wednesday, Secretary of State Rex W. Tillerson urged senators to oppose the measure so that Mr. Trump and his administration would have “the flexibility to turn the heat up” if necessary.

“I certainly agree with the sentiment that has been conveyed by several members from both parties that Russia must be held accountable for its meddling in U.S. elections,” he said. “I would urge Congress to ensure any legislation allows the president to have the flexibility to adjust sanctions to meet the needs of what is always an evolving diplomatic situation.”

The existing restrictions were put in place by President Barack Obama after Russia annexed Crimea in 2014. The new sanctions are intended to punish Russia for its role in the fighting in Syria and for interfering in the 2016 election.

The House has yet to take up the measure, which is an amendment to a bill that tightens sanctions on Iran for its ballistic missile tests. Republicans and Democrats have said they doubt Mr. Trump would veto the bill.

Last year, Mr. Trump told The New York Times that he questioned whether it was in the United States’ best interest to continue the sanctions on Russia.

A version of this article appears in print on , on Page A12 of the New York edition with the headline: Senate Votes To Cap Power Of President On Sanctions. Order Reprints | Today’s Paper | Subscribe