Many of the 47 House Democrats who joined Republicans Thursday in calling for tighter immigration restrictions on Middle East refugees had practical reasons for bucking President Barack Obama on the issue — including next year’s elections and polls that show the public on their side.

But that didn’t stop progressives, activists and pundits from blasting the party defectors after the vote.

“47 Democrats Just Voted for Terror,” read the headline over Charles P. Pierce’s Esquire piece. Huffington Post offered a handy list of the Democrats’ names – including phone numbers. “America’s Ugly Panic Gets Worse” wrote the Washington Post editorial board.

Democrats opposed to the new restrictions on immigrants from Syria and Iraq were dismayed: California Rep. Judy Chu, chairwoman of the Congressional Asian Pacific American Caucus, called the bill that passed by a veto-proof 289-137 margin “a mistake and a violation of our country’s values.”

“We might as well take down the Statue of Liberty,” said Rep. Jerrold Nadler, D-N.Y.

Still, an unbowed White House, despite the unexpectedly bipartisan rebuke from the House, renewed its promise to veto the bill — should it ever make it to the president’s desk. Minority Leader Harry Reid vowed the proposal won’t survive the Senate. “Don’t worry. It won’t get passed,” he told reporters Thursday. “Next question?”

Symbolic or not, Thursday’s House vote held significant risks for Democrats in swing districts, as well as for those lawmakers in safe districts eyeing statewide races down the road.

Nebraska’s Brad Ashford, a freshman Democrat who in 2014 managed to pull out a close win in his Republican-leaning Omaha district, took to the House floor Thursday to explain why he was abandoning Obama.

“In the wake of the horrific attacks in Paris, in my view a game changer, we must and are obligated to reassess our existing procedures,” Ashford said. “”I cannot sit back and ignore the concerns of my constituents and the American public.”

A couple of Florida Democrats facing big races next year — Rep. Patrick Murphy, who is running for the Senate seat being vacated by Marco Rubio, and Rep. Gwen Graham, who is seeking re-election in a district that leans heavily Republican — cited national security concerns in backing the GOP bill.

“As the granddaughter of a Christian who came to America after fleeing religious violence,” Graham said, “I do believe we have a role in helping peace-seeking refugees — but in light of new threats, we must strengthen our vetting process.”

Murphy defended the bill against critics who accused supporters of disregard for the suffering of refugees, saying the new regulations ensure “our entire intelligence community is on the same page without turning our backs on those fleeing violence and terror.”

California’s Jim Costa, who held onto his District 16 seat by less than 1,400 votes two years ago, said “my first responsibility is to protect and defend American citizens from all enemies, foreign and domestic.

“Let’s face it; these terrorists have declared war on Western civilization and our very way of life,” he said.

The president, who has sharply criticized Republican presidential candidates and governors for “slamming the door” on refugees in the wake of the Paris attacks, even lost a few Democrats who hold relatively safe seats — including Lloyd Doggett of Texas and Tulsi Gabbard of Hawaii, an Iraq veteran who called the bill “very short and simple … for those who have actually read it.”

Doggett, who won his San Antonio-area district handily in 2014, complained about the GOP bill but in the end signed on.

The bill, the American Security Against Foreign Enemies (SAFE) Act of 2015, was introduced earlier this week by Homeland Security Chairman Michael McCaul, R-Texas, and Rep. Richard Hudson, R-N.C., amid concerns that the Islamic State could hit the United States with an attack similar to the one the terror group launched against Paris seven days ago.

SAFE calls for a moratorium on Syrian or Iraqi refugees coming to the United States until each applicant has been certified as a non-threat by the secretary of Homeland Security, the director of the FBI, and the director of National Intelligence.

Lawmakers in favor of the new restrictions cited polls, including a Bloomberg survey released this week showing 53 percent of respondents opposed to the administration’s plans to resettle up to 10,000 refugees fleeing the Syrian civil war in the United States.

Thursday’s vote marked a surprising setback for a White House that has grown accustomed to imposing, at the last minute, its will on balky Democrats, as it did earlier this year to push through legislation clearing the way for the Trans Pacific Partnership.

Members said the arm-twisting didn’t work this time,

Rep. Gerald E. Connolly, D-Va., usually a reliable Obama ally, voted with Republicans after being debriefed on the president’s plans by White House Chief of Staff Denis McDonough and Department of Homeland Security Secretary Jeh Johnson.

“The administration representatives didn’t really present a compelling and cogent reason to vote no,” he told reporters.

“If you are going to send people home Thanksgiving week, you’re going to have to justify why you voted no on the only piece of legislation in front of us post Paris and it was a fairly modest bill,” Connolly said.

Nashville’s Rep. Jim Cooper, a member of the moderate Blue Dog Coalition, echoed that sentiment.

“America has always welcomed refugees and should continue to do so,” Cooper said. “Today’s vote won’t change that tradition. This bill merely reinforces existing law,” the Tennessee Democrat said.