The House of Representatives has overwhelmingly passed a sweeping, $638bn defence bill that would block President Barack Obama from closing the US detention facility at Guantánamo Bay, and limit his efforts to reduce nuclear weapons.

Ignoring a White House veto threat, the Republican-controlled House voted 315-108 for the legislation – which also authorises money for aircraft, weapons, ships, personnel and the war in Afghanistan. It must be reconciled with a Senate version before heading to the president's desk.

Despite last-minute lobbying by Obama counter-terrorism adviser Lisa Monaco, the House soundly rejected Obama's repeated pleas to shutter Guantánamo. In recent weeks, the president implored Congress to close the facility in Cuba, citing its prohibitive costs and its role as a recruiting tool for extremists.

A hunger strike by more than 100 of the 166 prisoners protesting against their conditions and indefinite confinement has prompted the fresh calls for closure. Obama is pushing to transfer approved detainees – there are 86 – to their home countries and lift a ban on transfers to Yemen. Fifty-six of the 86 are from Yemen.

The House voted down an amendment to close the naval detention centre by 31 December 2014 by 249 votes to 174. It also backed an amendment – by 236 to 188 – to stop the president from transferring any detainees to Yemen.

The restrictions in the House bill put it at odds with the Democratic-controlled Senate.

The Senate armed services committee's bill gives the defence department additional flexibility to transfer Guantánamo detainees to the US and other countries, with the objective of closing the detention facility there.

But, in a move that reflects deep divisions in Congress over Guantánamo's future, the committee did not hold votes on the provision in the bill, opting instead to have that debate when the legislation moves to the Senate floor.

In its current form, the Senate committee's legislation would permit transfer of terror suspects to the US if the Pentagon determines that doing so is in the interests of national security and that any public safety issues have been addressed, the committee said Friday in a statement detailing the bill's major provisions.

Detainees could be moved to foreign countries if they are determined to no longer be a threat to US security, the transfers are pursuant to court orders, or the individuals have been tried and acquitted, or have been convicted and completed their sentences.

Transfers to third countries also could occur if the Pentagon determines the move supports US national security interests and steps have been taken "to substantially mitigate the risk of the detainee re-engaging in terrorist activities," the committee said.

The defence policy bill also bars the Pentagon or the National Nuclear Security Agency from spending any money to implement the new Start treaty with Russia that the Senate ratified in December 2010 until the defence secretary provides certain information on reducing the US nuclear arsenal to Congress.

The bill also imposes new punishments on members of the armed services found guilty of rape or sexual assault as outrage over the crisis in the military has galvanised Congress.

Obama backs the measures, which would require a mandatory minimum sentence of two years in prison for a member of the armed services convicted of rape or sexual assault in a military court. The bill also would strip military commanders of the power to overturn convictions in rape and sexual assault cases.