Rabat- The Criminal Chamber at the Court of Appeal in Rabat acquitted former Moroccan Guantanamo detainee Younes Chekkouri on Thursday.

In May 2017, the Court’s First Trial Chamber had sentenced Chekkouri to five years in prison for “setting up a criminal gang and undermining the internal security of the State.”

Moroccan authorities had incarcerated Chekkouri on conspiracy charges when he arrived in Morocco in September 2015 following his release from the U.S. military detention facility in Cuba, where he had been detained for nearly 14 years.

Following his preliminary hearing, the investigating judge in charge of terrorism cases ordered his prosecution while allowing him to be free on bail in response to a motion from his defense.

Pakistani security officers arrested Chekkouri in December 2001, as he attempted to cross the Pakistan-Afghanistan border with other suspected al-Qaida fighters. He was later turned over to U.S. forces.

He previously told the Associated Press that he attempted to cross to Afghanistan to continue his study of Sufism, which he had been pursuing in various countries across the Islamic world, including Sudan, Yemen, and Syria.