Muktar Yahya Najee al Warafi, a Yemeni who served as a medic for Taliban forces in Afghanistan in 2001, is currently a detainee at the military prison at Guantanamo Bay, Cuba.

He is suing for release on the grounds that the war is over and the law authorizing it (and his detention) has expired. He cites several claims by White House officials, including President Obama’s declaration last January that “America’s longest war has come to a responsible and honorable end.”

Last week, U.S. District Judge Royce Lamberth denied Warafi’s petition. As long as hostilities continue, he writes, so does the war’s legal basis.

Although Warafi is not a serious threat, a ruling in his favor might have opened the prison gate for similar challenges by the 60 or so detainees there considered the “worst of the worst.” The need for the president and Congress to overhaul the war authorization and detainee policy remains urgent.

 Congress must act on the draft authorization for war against Islamic State that Obama sent in February. Lawmakers need to develop a compromise that will get Obama’s signature – ideally, one that supersedes the 2001 measure and the 2002 war authorization for Iraq and reconciles the continuing hostilities in those places with the newer threats to global peace.

 The U.S. needs to close Gitmo, ship home those detainees deemed unthreatening, transfer the hard cases to a new maximum-security facility in the domestic U.S., and codify a legally compelling plan for deciding which can be tried where and when.

The war is not over in Afghanistan, and it continues to rage in places like Iraq and Yemen. And it’s likely that some of the jihadists at Gitmo, if freed, would quickly rejoin that war. All the more reason to bring more clarity and legitimacy to our nation’s role in it.