Correction: An earlier version of this story said that Slahi’s cousin and brother-in-law were both senior figures in al-Qaeda. The cousin and brother-in-law are one person, not two different ones.

Mohamedou Ould Slahi, one of the most controversial and colorful prisoners at Guantanamo Bay, Cuba, and the author of a best-selling memoir about his time there, has been cleared for release from the military facility, U.S. officials announced Wednesday.

Slahi, 45, who was born in Mauritania, had appeared before a parole-style review board June 2 that recommended his transfer. In making its decision, the board said it considered the detainee’s “highly compliant behavior in detention.” There also were “clear indications of a change in the detainee’s mind-set.”

“I am just thrilled that he is finally cleared again and the government of Mauritania has said it welcomes him home,” said Nancy Hollander, one of Slahi’s attorneys.

The prison has 76 detainees, and 31 of them have been approved for transfer.

Slahi, who was subject to some of the harshest treatment meted out at Guantanamo Bay but cooperated with the U.S. military, was suspected of playing a role in the 2000 millennial plot that targeted tourist sites in Jordan and Los Angeles International Airport. Both his cousin and brother-in-law were senior figures in al-Qaeda, and Slahi pledged allegiance to Osama bin Laden in the early 1990s.

Slahi was detained in his native country in November 2001, turned over to the United States, and flown to Jordan for interrogation. After eight months in custody, he was flown in July 2002 to Bagram Air Base in Afghanistan and then moved the following month to Guantanamo Bay.

His book, “Guantánamo Diary,’’ which was published last year, is thought to be the only existing memoir written by a current detainee. It took years of legal maneuvering by his lawyers before the heavily redacted book could be published.

His torture included threatened sexual abuse, sleep deprivation, exposure to extreme temperatures, a simulated kidnapping, a mock execution on a boat, and the threat that the military would bring his mother from Mauritania to Guantanamo Bay and harshly interrogate her, according to a Senate investigation and other documents.

Slahi wrote that he thought coming to Cuba from Jordan and Afghanistan was a blessing, believing the United States would treat him humanely. But “the interrogation methods worsened considerably as time went by,” he wrote. His cell was kept was unbearably cold, he recalled. “I was shaking most of the time. I was forbidden from seeing the light of the day.”

He added: “I was living literally in terror.”

According to U.S. military files disclosed by the anti-secrecy group WikiLeaks, Slahi moved to Germany in 1990 to study electrical engineering but began to move in radical Islamist circles. He first traveled to Afghanistan in 1990. At a military tribunal in 2004, Slahi admitted that he traveled to Afghanistan to wage violent jihad, that he wanted to die for Islam and that he trained at an al-Qaeda camp near Kandahar.

“He was fighting against the communist government in 1990 with the mujahideen that the U.S. supported with millions of dollars,” Hollander said. “That was not the same al-Qaeda in 2001.”

In November 1999, Slahi moved to Canada. The next month, Canadian authorities questioned him about Ahmed Ressam, who was arrested with explosives while trying to cross the U.S.-Canada border. Ressam, an Algerian, was convicted of attempting to bomb Los Angeles International Airport and sentenced to 37 years.

In January 2000, Slahi returned to Mauritania because his mother was ill and he was arrested repeatedly there before being flown out of the country by the United States.

In 2010, a federal judge ruled that Slahi must be released from custody because the government was unable to prove that at the time of his capture he was part of al-Qaeda or was providing any support to the organization.

Hollander said the government’s accusations against her client are based on “information that was false.”

‘They never had anything on him,” she said. “He should never have been there.”

Read more: