WASHINGTON — A bill that would have greatly tightened screening procedures on refugees from Syria and Iraq failed on a procedural vote in the Senate on Wednesday, saving President Obama from another vexing veto scenario on an issue that has divided the country.

While the measure passed overwhelmingly in the House late last year, Senate Democrats had vowed to stop it, and the matter quickly became enmeshed in presidential politics, presaging what is all but certain to be a contentious and protracted proxy battle for the White House fought in Congress this year.

“Over and over again, Republicans remain committed to pledging loyalty to the divisive platform they have built for Donald Trump,” said Senator Harry Reid of Nevada, the Democratic leader, tying the issue of the refugee screening to Mr. Trump’s proposal to bar Muslims from entering the United States.

Three Republican senators running for president left the campaign trail briefly and returned to vote on the measure, an outgrowth of the terrorist attacks in Paris and elsewhere last year and of increasing unease among American voters over the nation’s security.