The House voted Thursday to block any more transfers of detainees from Guantanamo Bay under President Obama, striking a symbolic blow after he signaled last week he still believes there’s a chance to shutter the prison before he leaves office.

The 244-174 vote, which broke chiefly along party lines, is the latest in a series of measures that have tied Mr. Obama’s hands, keeping him from having free rein in disposing of the remaining 61 detainees.

Mr. Obama has vowed to veto the bill should it reach his desk, and with just a few weeks left before the elections it’s not clear the Senate will even act on it — but Republicans wanted voters to see where their lawmakers stood, and quickly fired off emails blasting vulnerable House Democrats who voted against the legislation.

The vote came a day after U.S. intelligence officials confirmed that two more former Guantanamo detainees released during Mr. Obama’s tenure have rejoined the ranks of terrorists.

“The administration should heed the will of the House and cease its planned transfers of more terrorists back to their host countries,” said House Speaker Paul D. Ryan. “For the president, this is about keeping a campaign promise. For us, this is about keeping Americans safe.”

Democrats, though, said as long as the prison is open, it saps American moral leadership.

“This bill is un-American in the extreme,” said Rep. Jerrold Nadler, New York Democrat.

Mr. Obama is already long overdue on his campaign promise to shutter the prison in 2010. He’s released 161 detainees, but has struggled to free the remaining ones.

Last week in Asia he said he still has hopes of closing the facility before his term ends in January.

Republicans said that would mean bringing some of them to the United States — and endangering neighborhoods here.

“Which of you want those terrorists brought to your community?” said Rep. Randy Forbes, Virginia Republican. “You have just put a target on every school, every business, every mall in that community.”

Of the Guantanamo inmates still detained, 20 have been cleared for transfer, with the administration saying they won’t be prosecuted and don’t pose a danger if released.

Republicans said they want the next president to make a final decision on them, and said that’s one reason they passed the bill.

White House press secretary Josh Earnest countered that former President George W. Bush, who opened the prison in the first place, wanted to close it.

And he said the recidivism rate under Mr. Obama — some 5.6 percent of those released since 2009 have been confirmed to have returned to the battlefield — was a sign of progress.

“That’s an indication of how rigorous the process is when we are negotiating with other countries around the world to take these detainees and impose requirements that don’t put the United States or the American people at risk,” he said.

New figures from the Director of National Intelligence this week showed 9 detainees released under Mr. Obama have rejoined the fight — up two in this year alone. Another 11 are suspected of doing so.

It’s still far lower than the rate of those released under Mr. Bush: some 21 percent are confirmed to have returned to the battlefield, and another 14 percent are suspected of doing so.