A former child soldier from Sierra Leone detained for more than two years in Minnesota was released Thursday by Immigration and Customs Enforcement (ICE) in Minnesota after a ruling by a federal magistrate judge.

Nelson Kargbo, 30, a refugee who has lived in Minnesota since 2000, was ordered released from the Carver County jail on Oct. 2 by U.S. Magistrate Judge Leo Brisbois.

Kargbo, 30, of Woodbury, had been convicted of 11 criminal offenses, including 10 misdemeanors and one felony gross misdemeanor.

Two of the offenses were deemed crimes “of moral turpitude” — shoplifting and terroristic threats — and made him subject to deportation, leading to his arrest by ICE and incarceration in 2013.

Kargbo’s attorneys argued that the crimes were the result of post-traumatic stress disorder and mental illness and that he has turned his life around.

Despite ICE’s desire to deport Kargbo, an immigration judge earlier determined that it would be dangerous for him to be sent back to Sierra Leone, where he had been forced to join a brutal insurgent group in the 1990s. Nonetheless, immigration authorities continued to hold him.

The U.S. Department of Homeland Security contended that his removal was still likely and wanted to find a country to deport him to. But Brisbois said the department had produced no evidence in court that he should be removed to another country and that the amount of time it could hold him had expired.

The petition for Kargbo’s release was sought and won by the American Civil Liberties Union of Minnesota, law students working through the Center for New Americans at the University of Minnesota, and attorneys with the Dorsey & Whitney law firm.