The Republican-controlled House voted Tuesday to condemn President Barack Obama for failing to give 30 days notice to Congress about the exchange in May of American prisoner Bowe Bergdahl for five Taliban leaders held at the U.S. prison at Guantanamo Bay, Cuba.

The vote was 249-163, with 22 Democrats — many locked in tough re-election races — breaking ranks and backing the nonbinding resolution.

“By setting free five top Taliban commanders from U.S. custody, the Obama administration made Americans less safe,” House Speaker John Boehner said in a statement.

The vote castigating Obama came at a crucial moment for the administration as it seeks to rally international and congressional support for steps to combat the rising threat of Islamic state militants in Iraq and Syria.

“What poor timing for a resolution,” said Rep. Sheila Jackson Lee, D-Texas.

Rep. Alcee Hastings, D-Fla., suggested that the House vote on the measure less than two months before the election was simply an effort to appease core Republican voters. But Republicans said Obama clearly violated a law requiring the administration to notify Congress at least 30 days before transferring prisoners from the Guantanamo Bay prison — a conclusion the nonpartisan Government Accountability Office also reached in a report last month.

“The administration deprived Congress of the opportunity to consider the national security risk or the repercussions of negotiating with terrorists,” said Rep. Howard “Buck” McKeon, R-Calif., chairman of the House Armed Services Committee.

Five senior Taliban were released from Guantanamo in exchange for the Army sergeant who had disappeared from his post in eastern Afghanistan on June 30, 2009. The Taliban are to remain in Qatar for a year.

The administration has offered a number of explanations for keeping Congress in the dark, including concern about Bergdahl’s health and safety, which it said required speedy action to ensure, and worries that lawmakers would divulge details of the deal and scuttle it. Obama has said his constitutional authority as commander in chief superseded the requirement to apprise lawmakers.

The resolution, which lacks the force of law and will not be considered in the Democratic-majority Senate, “condemns and disapproves of the failure of the Obama administration to comply with the lawful 30-day statutory reporting requirement in executing the transfer of five senior members of the Taliban from detention at United States Naval Station, Guantanamo Bay, Cuba.”

The resolution does, however, express relief that Bergdahl has returned safely to the United States.