(CNN) -- President Barack Obama appeared to have his most promising window yet in the coming months to keep his promise to close the military-run prison at Guantanamo Bay.
Then he made the Sgt. Bowe Bergdahl swap.
The trade of five Taliban members at Guantanamo to free Bergdahl, the last remaining American captive in the Afghanistan war, ignored congressional restrictions President Barack Obama signed in the annual defense policy law that require him to notify Congress 30 days before transferring prisoners.
In the weeks before, administration officials and Democratic aides working on the closure issue were optimistic that they could find a way to remove the most difficult congressional restrictions when a new law is approved later this year.
Hints at that optimism showed up in Obama's recent speeches, where he has mentioned his hopes to close the prison housing terror detainees after long largely avoiding the issue.
House and Senate versions of the upcoming defense authorization law still contain hurdles.
The Senate version would allow transfers of Guantanamo prisoners to the United States on the condition that the administration first submits a closure plan and Congress has a chance to disapprove.
Sen. Carl Levin, the Armed Services Committee chairman, who for years was cautious about Obama's closure plans, has warmed to the idea that shutting the prison can be done safely if the administration has laid out a plan.
To that end, the Justice Department in recent weeks issued a legal opinion saying that Guantanamo detainees transferred to the United States for trial or indefinite detention under the laws of war don't have rights under immigration law to be released on U.S. soil. The House version of the bill still blocks transfers.
The White House has also issued a veto threat if the restrictions survive the period of legislative negotiation that produces a final law.
Administration officials note that Obama attached a notice when he signed the current defense policy law calling the restrictions unconstitutional and reserving the right to bypass the notification requirement if there was a national security interest.
The administration has said the exchange that led to Bergdahl's freedom was expedited due to fears his life was in jeopardy, though the administration had notified Congress that an exchange was a possibility.
Rep. Buck McKeon, chairman of the House Armed Services Committee, was angered by the Bergdahl swap and appears to have stiffened his opposition.
In an interview with CNN on Sunday, McKeon said despite Obama's plan to close Guantanamo, "Congress has passed a law and he has signed a law that he will not close Guantanamo. Whatever his desires are, that does not conform to the law and he is the chief administrator of the law of the nation and should uphold his constitutional obligation to follow the law."
A senior administration official told CNN that Obama knew his decision to secure Bergdahl's release through a prisoner exchange would generate debate and would spark a discussion about both winding down the war in Afghanistan and closing the prison at Guantanamo.
"With respect to the closure of the detention facility at Guantanamo Bay, the President has said repeatedly -- in last year's speech at (National Defense University), in this year's State of the Union, and in last week's speech at West Point -- that he believes the continued operation of the detention facility harms our national security," Caitlin Hayden, spokeswoman for the National Security Council.
"Our policy on Guantanamo Bay is the same now as it was prior to Sergeant Bergdahl's recovery -- the United States will repatriate, resettle, or prosecute detainees at Guantanamo Bay to the greatest extent possible, consistent with U.S. national security interests and our humane treatment policy," she said.
The Bergdahl exchange muddled the administration's claim of laying the blame on Congress for blocking the Guantanamo closure. Obama demonstrated that he believes he is justified in releasing prisoners without congressional approval.
Administration officials have said Obama prefers to work with Congress to carry out the closure.
Some Democrats also have expressed qualms about Obama's handling of the Bergdahl swap.
Sen. Diane Feinstein said she would like Obama to brief the Intelligence Committee. Levin said he plans to question administration officials about what impact the 30-day notification would have had on the prisoner exchange. Still, he said the administration satisfied the law.
"We received a detailed classified notification from the secretary of defense that satisfies the many substantive certification requirements of the National Defense Authorization Act for Fiscal Year 2014," Levin said in a statement Tuesday.
Levin said later that the classified notification came two days after Bergdahl's release, but Congress had been given due notice last December that the President may choose to not follow the requirements set out by Congress.
"The President put Congress on notice on December 23, 2013, that he intended to exercise his powers as commander in chief, if necessary, 'to act swiftly in conducting negotiations with foreign countries regarding the circumstances of detainee transfers.' While the President cannot change the law with a signing statement, given that notice, members of Congress should not be surprised that he acted as he did in the circumstances that existed."
CNN's Jim Acosta, Dana Bash and Ted Barrett contributed to this report.