WASHINGTON  Congress voted Wednesday to impose strict new limits on transferring detainees out of the Guantánamo Bay prison, dealing a major blow to President Obama’s vows to shut down the center and give federal court trials to many of the prisoners.

The Guantánamo provisions were contained in a major defense authorization bill, which both chambers passed on the last day of Congress’s lame-duck session. It is considered highly unlikely that Mr. Obama will veto the bill because it also authorizes billions in spending for the wars in Afghanistan and Iraq.

Robert M. Chesney, a University of Texas law professor who specializes in national security matters, said the legislation would make it even harder to close the prison, at the American military base in Cuba. He said the next Congress, in which Republicans will have more power, was likely to keep or even intensify the restrictions.

“A Democratic Congress has done its level best to prevent prosecutions in civilian court,” Professor Chesney said.