For the 18-year lifespan of the war on terrorism, an obscure provision of the PATRIOT Act permitting the indefinite detention of non-citizens on U.S. soil has gone unused. But to keep a Palestinian man behind bars even after he finished serving his sentence, the Trump administration has fired this bureaucratic Chekhov’s gun.

Adham Amin Hassoun, now in his late 50s, has spent nearly the entire war on terrorism in cages. First picked up on an immigration violation in June 2002, he ended up standing trial alongside once-suspected “dirty bomber” Jose Padilla. But Hassoun was never accused of any act or plot of violence. His crime was cutting checks to extremist-tied Muslim charities operating in places like Kosovo and Chechnya that Congress outlawed after the 9/11 attacks. Hassoun wrote all but one of those checks before 9/11.

Sentenced to 15 years in federal prison, Hassoun should have been a free man in 2017. Instead, he found himself in the custody of Immigration and Customs Enforcement, which locked him up in western New York. It was there that Hassoun’s case turned extraordinary.

ICE wanted to deport Hassoun, but his statelessness as a Palestinian got in the way. No country—not the Lebanon of his birth, not the Israel that occupies the West Bank and Gaza—was willing to take him. Aided by attorneys at the University of Buffalo Law School, Hassoun in January won what should have been his freedom, on the grounds that his deportation was unlikely.

The Trump administration instead declared him a threat to national security. It did so at first using an also-obscure immigration regulation designed to sidestep a 2001 Supreme Court ruling imposing a six-month detention limit. And it was aided by a testimonial, under seal, of Hassoun’s alleged misdeeds behind bars as related by what his attorneys describe as jailhouse snitches who provided second- or third-hand accounts. But as the government fought what had become a habeas corpus case for Hassoun’s release, the Department of Homeland Security invoked, for the first time in U.S. government history, section 412 of the PATRIOT Act.

Section 412 gives the government broad powers to detain non-citizens on American soil whom it can’t deport but deems, on “reasonable grounds,” to be engaged in “activity that endangers the national security of the United States.” It makes that determination for a six-month period that it can renew without limit. To little fanfare, the former acting secretary of Homeland Security, Kevin McAleenan, informed Hassoun on Aug. 9 that “you will therefore remain in the custody of U.S. Immigration and Customs Enforcement (ICE) pending your removal from the United States or reconsideration of this decision.”

Attorneys for Hassoun, who were in federal court on Friday to argue for his freedom, are stunned at the invocation of Section 412. They noted that the PATRIOT Act provision is written to “take [a non-citizen] into custody,” not to retroactively designate someone already in detention as a threat.

“If the government were to prevail in its claim of extraordinary and unprecedented executive power, the government would be free to lock up non-citizens indefinitely based solely on executive say-so, even after they completed serving their sentences,” said Jonathan Hafetz, a lawyer with the American Civil Liberties Union.

ICE, citing the ongoing litigation, declined comment. The Department of Homeland Security did not respond to requests for comment.

McAleen claimed in his August invocation of the PATRIOT Act that he did so because Hassoun “assumed a leadership role in a criminal conspiracy to recruit fighters and provide material support to terrorist groups, and because you pose a continuing threat to recruit, plan, participate in, and provide material support for terrorist activity.”

Yet the federal judge in his criminal case, Marcia G. Cooke, painted a far different picture of Hassoun during his 2008 sentencing. There was “no evidence that these defendants personally maimed, killed or kidnapped anyone in the United States or elsewhere,” and the government could find “no identifiable victims” as the result of their actions, she said.

Cooke, a George W. Bush appointee, specifically rejected the life sentence the Justice Department sought for Hassoun, noting that years of government surveillance on him never resulted in his criminal arrest. “This fact does not support the government’s argument that Mr. Hassoun poses such a danger to the community that he needs to be imprisoned for the rest of his life,” Cooke ruled.

“ This is Guantanamo on domestic soil. ” — Nicole Hallett, University of Buffalo Law School

The administration’s portrayal of Hassoun contrasts with the man Nicole Hallett and Jonathan Manes, professors at the University of Buffalo Law School, meet nearly every week at the ICE detention center in Batavia.

They described someone who operates as a paternal figure to other Muslim detainees. He aids their court cases by poring over the law books in the library. Locked up with about 30 other immigration detainees, his red jumpsuit marking him as a security threat, Hassoun wakes early to help prepare breakfast in the facility kitchens. Even after what has become a 17-year ordeal in various cells, he keeps up with American pop culture, and is a fan of the USA Network legal drama Suits.

Using Section 412 of the PATRIOT Act to prolong Hassoun’s confinement was so unlikely that a March New York Times story referenced it only as a tactic by government attorneys to bolster the legitimacy of the immigration regulation. Five months later, it was a reality.

To Hallett, the shock of Hassoun’s detention even after he served his criminal sentence, matched with the unprecedented the means the administration is using to keep him locked up, testifies to the degradation of the rule of law in the post-9/11 era.

“This is Guantanamo on domestic soil,” Hallett said. “The government is trying to detain him as long as it wants, and that prison happens to be in Batavia, New York, not at Guantanamo Bay.”

Hassoun is said to be mentally sharp. His physical health is a different question. Twice in Batavia he has been hospitalized, his attorneys said, after hunger strikes to protest his confinement exacerbated his diabetes and a pre-existing heart condition.

Then comes the loneliness and the sense of injustice. His wife moved to Lebanon with their children over a decade ago. Last year, Hassoun told Hallett and Manes about his youngest son’s acceptance to college; the young man was 2 years old when his father was arrested. Hassoun believes that his prosecution was the result of his 2002 decision, while in immigration custody, not to turn federal informant.

Unlike many immigrant detainees, Hassoun isn’t contesting deportation. His attorneys said he would leave the country if one would take him—another eerie parallel to Guantanamo. “Adham just wants to live peacefully someplace,” Manes said. A sister in Florida, a U.S. citizen, could assume custody for him under supervised release.

“He feels quite a bit of angst over [the fact that] he had served his sentence and feels like he should be released,” Hallett said. “He’s worried about dying in prison.”