ROCHESTER, N.Y. — A man convicted of terrorism-related crimes, who served his sentence and was then detained by U.S. Immigration and Customs Enforcement, has been deported after a legal battle to hold him indefinitely stalled.

Federal immigration authorities held Adham Amin Hassoun until Tuesday at a detention facility in Batavia, New York, since his release from prison in 2018. Previously, they had argued in court that they had the authority to detain him indefinitely under the Patriot Act until they could find a country willing to accept him.

Hassoun, 58, is a Palestinian born in Lebanon. In 2007, he was convicted along with Jose Padilla, who is still imprisoned, of conspiracy to murder, kidnap and maim people in a foreign country.

Padilla, a U.S. citizen, was initially detained as an enemy combatant in 2002 on suspicions he planned to set off a radioactive "dirty bomb," but those allegations were ultimately dropped in favor of charges that he, Hassoun and another conspirator sent money, recruits and supplies to Islamic extremist groups.

Prosecutors said Hassoun recruited Padilla at a Florida mosque to attend a terrorist training camp in Afghanistan.

Authorities did not disclose Hassoun's destination after he left the country on Tuesday, the Democrat and Chronicle reported.

Padilla's expected release date from prison is 2026.

Earlier this summer, federal prosecutors had argued at a hearing that Hassoun remained a threat to national security, but ultimately withdrew testimony from another detainee at the Batavia detention facility, who claimed Hassoun told him about plans to commit crimes upon his release. Hassoun's attorney said the claims were fabricated, the Observer Dispatch reported.

U.S. District Judge Elizabeth Wolford ruled against the government and ordered Hassoun's release.

Hassoun immigrated to the Florida in 1989, married and had three children, all of whom are American citizens. His family moved to Lebanon after his arrest, the Buffalo News reported.

One of Hassoun's attorneys, Jonathan Manes, told the Democrat and Chronicle in an email: "After 18 years of imprisonment and nearly 1 1/2 years detained unlawfully under the Patriot Act, he is now a free man."