CHICAGO -
In his press conference this week, President Barack Obama repeated that he wanted to shut Guantanamo Bay but blamed Congress for stopping him. "They would not let us close it," he said. But that's wrong. President Obama can lawfully release the detainees if he wants to. Congress has made it difficult, but not impossible. Whatever he's saying, the president does not want to close the detention center - at least not yet.

The relevant law is the National Defense Authorization Act of 2012 (NDAA). This statute confirms the president's power to wage war against al-Qaida and its associates, which was initially given to him in the Authorization for Use of Military Force (AUMF) passed shortly after 9/11. The NDAA also authorizes the president to detain enemy combatants, and bans him from transferring Guantanamo detainees to American soil.

The NDAA does not, however, ban the president from releasing detainees. Section 1028 authorizes him to release them to foreign countries that will accept them - the problem is that most countries won't, and others, like Yemen, where about 90 of the 166 detainees are from, can't guarantee that they will maintain control over detainees, as required by the law.

There is another section of the NDAA, however, which has been overlooked. In section 1021(a), Congress "affirms" the authority of the U.S. armed forces under the AUMF to detain members of al-Qaida and affiliated groups "pending disposition under the law of war." Section 1021(c)(1) further provides that "disposition under the law of war" includes "Detention under the law of war without trial until the end of the hostilities authorized by" the AUMF. Thus, when hostilities end, the detainees may be released.

The president has the power to end the hostilities with al-Qaida - simply by declaring their end. This is not a controversial sort of power. Numerous presidents have ended hostilities without any legislative action from Congress - this happened with the Vietnam War, the Korean War, World War II, and World War I. The Supreme Court has confirmed that the president has this authority.

Nor is there any reason why President Obama couldn't declare the war with al-Qaida at an end. The group's original core is essentially gone. A defense department official recently hinted that the end of the conflict with al-Qaida is approaching, while the troop drawdown in Afghanistan will be completed next year. Associates and fellow travelers continue to exist, but the president is free to end hostilities even so; this, too, has happened many times before, like in Korea and Vietnam.

It's true that section 1027, the provision of the NDAA that flatly prohibits the use of funds to transfer Guantanamo detainees to U.S. soil, appears to make it impossible to transfer them to prisons inside the U.S. But if that's the case, and detainees can't be transferred to foreign countries under section 1028 either, then section 1027 essentially orders the president to detain non-combatants indefinitely, and such an order is of dubious constitutionality at best. When the Supreme Court approved indefinite detention of members of al-Qaida and the Taliban in Hamdi v. Rumsfeld in 2004, the premise was the president's military authority under the AUMF and the "active combat operations against Taliban fighters" in Afghanistan. When active combat operations cease, this pillar of the Supreme Court's opinion falls. And while courts have been reluctant to grant rights to detainees that constrain the president's power, they are likely to take the opposite view if he advances those rights while declaring that hostilities have ended.

The better interpretation of section 1027, one that avoids constitutional difficulties, bans transfers from Guantanamo to the U.S. only as long as hostilities continue. Courts have recognized repeatedly that the president can act on reasonable interpretations of statutes when they are ambiguous or contain internal contradictions; that statutes should be read to avoid constitutional problems like the one mentioned above; and that the president is entitled to special deference when laws touch on his foreign affairs and military powers. Yet another rule discourages interpretations of statutes that violate international law - which requires enemy combatants to be released at the end of hostilities unless they are convicted of crimes. For all these reasons, if President Obama were to declare an end of hostilities with al-Qaida and release detainees, he would be on reasonable legal ground. And it's not as though Obama has been shy about asserting executive power when Congress blocks an objective he cares about. His military intervention in Libya in defiance of the War Powers Act (and legal advice from some of his own lawyers) is one example.

If Obama declared hostilities at an end, the Guantanamo detainees would be no different from people who were washed up on U.S. territory by accident, like shipwrecked sailors. Those who pose no danger to the United States (about 86 of the 166), and cannot be returned to their countries, could receive refugee status under existing laws. Those who are known to be dangerous could be arrested under criminal law. If I am correct that section 1027 is unconstitutional, both groups could be brought to the United States. The detainees we cannot convict would be released. That may be politically unpalatable but it is legally unimpeachable.

Congress would squawk, but only a veto-proof majority of Congress would have standing to challenge the president in court, and it is hard to imagine that such a majority would sue. And even if it did, courts tend to duck disputes like this between the branches.

President Obama may worry that if he declares an end of hostilities with al-Qaida, he would need to terminate his beloved drone program, which operates in part under authority of the AUMF. But ample legal precedent shows presidents can use military force under their constitutional powers; and, in any event, nothing would stop President Obama from continuing the AUMF with respect to associates of al-Qaida. And if al-Qaida rises from the dead, Congress will eagerly supply him with a new law to fight it.

The real issue here, of course, is that Congress has given the president a convenient excuse for not doing something he doesn't really want to do anyway. The public wants to keep Guantanamo open. Shutting it would generate a serious backlash that enraged members of Congress would whip up. It also matters that President Obama does not object to indefinite detention, but to the island prison itself. That is why he wants to move detainees to a supermax in the United States, not release them. But doing so would make clear that his campaign promise to shut down Guantanamo Bay was an empty one. The place of indefinite detention would change; the system supporting it would not. He does better with headlines like "Congress, rules keep Obama from closing Guantanamo Bay" than with "Obama moves detainees to U.S. soil where they will remain forever." The president will not shut Guantanamo, and the reason is politics, not law. If you don't like this choice, blame him.

Posner, a professor at the University of Chicago Law School, is a co-author of "The Executive Unbound: After the Madisonian Republic and Climate Change Justice."

Sign up for the Opinion newsletter and get the latest analysis delivered to your inbox.