Razor wire tops the fence of the US prison at Guantanamo Bay in this library photo.
CNN  — 

A federal judge ruled that the detention of one of the 39 detainees being held at the US military prison in Guantanamo Bay is unlawful, according to the detainee’s lawyer.

On Tuesday, US DC District Court Judge Amit Mehta ruled that the detention of Asadullah Haroon Gul is unlawful and granted Gul’s petition for a writ of habeas corpus.

Though Judge Mehta’s ruling is not publicly available, one of Gul’s attorneys, Tara Plochocki, was permitted to state that Gul won the case but could not provide details about the reasoning behind the judge’s ruling, because that information is classified, she said. She expects an unclassified version of the ruling to be released in the coming months.

Gul, an Afghan national who grew up largely in a refugee camp in Shamshato, Pakistan, was accused of being a member of an extremist group called Hezb-e-Islami/Gulbuddin, which was known as HIG at the time. It has since become known as Hezb-e-Islami Afghanistan (HIA). HIA was deemed an “associated force” of al Qaeda by the US government.

Gul conceded that he had been a member of HIG, now known as HIA, at the time, but his defense attorneys argued that the group entered into a peace treaty with the Afghanistan government in 2016.

Gul has been detained at Guantanamo since June 2007.

Habeas corpus is a legal principle that allows people who believe they are being held unlawfully in prison or detention to challenge it, and successful challenges can lead to a detainee’s release.

This is the first time a detainee at the Guantanamo Bay prison has won a habeas petition in ten years, Plochocki said. The US Supreme Court ruled in 2008 that detainees at the Guantanamo prison did have the right to habeas corpus, but several habeas challenges to detentions at the facility have failed in the past decade, Plochocki said.

Gul’s lawyers had also filed a motion for release on the basis that the Geneva Convention requires release at the end of hostilities, but that motion was denied, Plochocki said.

Plochocki has been working on Gul’s case since it was filed in 2016, she said, along with her co-counsel Mark Maher, who works for the human rights organization Reprieve US. Detainees at the Guantanamo facility are not able to have phone calls with their lawyers unless they are approved and arranged by the Defense Department. Because of this, even though the ruling was issued on Tuesday, Gul has yet to be informed that he won, Plochocki said.

“We waited for hours in the secure facility for the decision to arrive,” Plochocki said. “When we got it, we tore it open and were just elated.”

Gul was also cleared by the Periodic Review Board on October 7 for transfer out of the prison. The Periodic Review Board is a government entity created during the Obama administration to determine whether detainees being held at the prison were guilty or not.

The Periodic Review Board ruled that Gul was no longer a threat to national security and did not need to be held at the Guantanamo facility because Gul did not have a leadership role in HIG and there was a “lack of a clear ideological basis for his prior conduct,” the summary of the final determination in Gul’s case states.

Although Gul was cleared by the PRB and has now won his habeas petition, that does not guarantee he will leave the prison soon. Several detainees have been cleared by the review board but still remain at the prison, some for as long as a decade since they received their clearance from the PRB. Once a detainee is cleared by the board, the US government must still find a country willing to accept a detainee according to whatever terms the US government might set.