The prisoner swap that freed Sgt. Bowe Bergdahl was legal, the White House insisted Tuesday, as President Barack Obama defended the deal at a news conference in Poland.

A statement from the White House said the president's power under the Constitution trumps a law requiring Congress get 30 days notice.

"Delaying the transfer in order to provide the 30-day notice would interfere with the Executive’s performance of two related functions that the Constitution assigns to the President: protecting the lives of Americans abroad and protecting U.S. soldiers," said Caitlin Hayden, spokeswoman for the National Security Council. "Because such interference would significantly alter the balance between Congress and the President, and could even raise constitutional concerns, we believe it is fair to conclude that Congress did not intend that the Administration would be barred from taking the action it did in these circumstances."

"The executive branch must have the flexibility, among other things, to act swiftly in conducting negotiations with foreign countries regarding the circumstances of detainee transfers," Obama said in his signing statement.

Obama also defended the Bergdahl transfer, saying at a Warsaw news conference that he had consulted with Congress "for quite some time" about the possibility of a prisoner transfer, but said the process was "truncated" because of the risks to Bergdahl and the desire not to miss a window for securing his release.

He acknowledged that the five Taliban detainees could return to fight against the United States, but said that he would not have agreed to the deal if he thought it would hurt national security.

"We will be keeping eyes on them," he said.

Here's the full memo from Hayden:

I’d like to explain why, given the credible reports regarding the risk of grave harm to Sergeant Bergdahl and the rapidly unfolding events surrounding his recovery, it was lawful for the Administration to proceed with the transfer notwithstanding the notice requirement in Section 1035(d) of the FY14 NDAA.
First, there is no question that the Secretary made the determinations required to transfer the detainees under Section 1035(b) of the FY 2014 NDAA. Section 1035(b) states that the Secretary of Defense may transfer an individual detained at Guantanamo to a foreign country if the Secretary determines (1) that actions have or will be taken that substantially mitigate the risk that the individual will engage in activity that threatens the United States or U.S. persons or interests and (2) that the transfer is in the national security interest of the United States. The Secretary made those determinations.
With respect to the separate 30-day notification requirement in Section 1035(d), the Administration determined that the notification requirement should be construed not to apply to this unique set of circumstances, in which the transfer would secure the release of a captive U.S. soldier and the Secretary of Defense, acting on behalf of the President, has determined that providing notice as specified in the statute could endanger the soldier’s life.
In these circumstances, delaying the transfer in order to provide the 30-day notice would interfere with the Executive’s performance of two related functions that the Constitution assigns to the President: protecting the lives of Americans abroad and protecting U.S. soldiers. Because such interference would significantly alter the balance between Congress and the President, and could even raise constitutional concerns, we believe it is fair to conclude that Congress did not intend that the Administration would be barred from taking the action it did in these circumstances.
The President also has repeatedly expressed concerns regarding this notice requirement. For example, the President’s FY14 NDAA signing statement indicated that “Section 1035 does not, however, eliminate all of the unwarranted limitations on foreign transfers and, in certain circumstances, would violate constitutional separation of powers principles. The executive branch must have the flexibility, among other things, to act swiftly in conducting negotiations with foreign countries regarding the circumstances of detainee transfers.” To the extent that the notice provision would apply in these unique circumstances, it would trigger the very separation of powers concerns that the President raised in his signing statement.
In these unique circumstances, in which the Secretary of Defense made the determinations required by Section 1035(b) and in light of the Secretary’s assessment that providing notice as specified in Section 1035(d) could endanger the soldier’s life, the Secretary of Defense’s failure to provide 30 days’ notice under Section 1035(d) was lawful.