A federal judge has rejected a legal challenge from a Guantanamo Bay inmate who said his continued imprisonment was unlawful since President Barack Obama had declared an end to the war in Afghanistan. The detainee has been held for 13 years.

The challenge brought by lawyers for detainee Muktar Yahya Najee al-Warafi said the Obama administration’s statement that the war in Afghanistan had come to an end made their client’s detention unlawful under the Authorization for the Use of Military Force of 2001. The authorization provides legal justification for imprisoning foreign fighters captured overseas.

The plaintiff’s argument also pointed to President Obama’s January 2015 speech declaring that “our combat mission in Afghanistan is over.”

READ MORE: Obama Gitmo plan: Kick out half, bring in half

The Washington, DC federal judge, Royce Lambert, wrote in his 14-page opinion that the president’s statement notwithstanding, the government had offered “convincing evidence the US involvement in the fighting in Afghanistan, against Al-Qaeda and Taliban forces alike, has not stopped,” and that al-Warafi’s detention remains legal.

“A court cannot look to political speeches alone to determine factual and legal realities merely because doing so would be easier than looking at all the relevant evidence,” Lambeth wrote, according to a report by the Associated Press. “The government may not always mean what it says or say what it means.”

Brain Foster, a lawyer for al-Warafi, said the judge’s opinion amounted to “a rubber stamp for endless detention” and would review the opinion to decide whether to appeal.

Foster also took to Twitter to say al-Warafi had worked in medical clinics in Afghanistan, a position that would provide him with protection under The Geneva Conventions.

#Warafi worked in medical clinics in Afgh. for 2 months in 2001. Judge says US can keep him in #GTMO as long as there's "fighting." 1/2 — Brian Foster (@fosterbr2013) July 30, 2015

There will always be "fighting" in Afgh. So #Warafi was just sentenced to life in #GTMO (or wherever) for providing medical care. 2/4 — Brian Foster (@fosterbr2013) July 30, 2015

Al-Warafi, a Yemeni, was captured in Afghanistan by the Northern Alliance in 2001 before being detained by the US at Guantanamo in 2002.

More than 700 inmates have been held at the Guantanamo Bay prison in Cuba, at a cost of more than $5 billion, since it opened in 2002 in the wake of the 9/11 attacks. The facility has been mired in scandal throughout its history, with allegations of torture, force feeding and sexual abuse.

There are still 116 detainees at the prison. Speaking at national security conference in Aspen, Colorado on July 24, Department of Homeland Security Secretary Jeh Johnson said it “doesn’t make fiscal sense” to keep Guantanamo open.

READ MORE: ‘Doesn’t make any fiscal sense’ to keep Gitmo open – DHS secretary

Johnson said that it costs nearly $900,000 per year to house each prisoner at Guantanamo, amounting to a total cost of more than $100 million per year. In comparison, he said the cost of housing an inmate in a high-security federal prison was $80,000.