Rene Lima-Marin has been detained by immigration agents after a judge ordered his early release from prison. The Colorado man convicted of kidnapping and robbery had turned his life around twice after first mistakenly being sentenced to 98 years in jail, then mistakenly released.

Rene Lima-Marin, 36, was preparing to be released from prison again Wednesday after Arapahoe County Chief District Judge Carlos Samour ordered his release and called his reincarceration “utterly unjust.” He was then immediately detained by Immigration and Customs Enforcement (ICE) officials.

On Tuesday, Samour ordered the Colorado Department of Corrections to release Lima-Marin, who was convicted on multiple counts of robbery, kidnapping and burglary for robbing two video stores in 1998 when he was 19 years old. Due to a clerk’s error, Lima-Marin’s sentences were listed as consecutive instead of concurrent, giving him a 98-year sentence, according to the Denver Post.

After Lima-Marin served eight years in prison, another error was made. He was mistakenly released. During the six years he spent as a free man, Lima-Marin got married, raised a family and worked a steady job before the state noticed their mistake and Lima-Marin’s sentence was reinstated. He voluntarily left his family and turned himself over to the police.

Lima-Marin served nearly three years in prison, until Samour issued a 165-page ruling on Tuesday that granted Lima-Marin’s release. In the ruling, he called Lima-Marin’s re-incarceration “utterly unjust.”

“Requiring Lima-Marin to serve the rest of his prison sentence all these years later would be draconian, would deprive him of substantive due process, and would perpetrate a manifest injustice,” the judge wrote in a court order obtained by the Denver Post.

“Accordingly, the government is deemed to have waived its jurisdiction to compel him to serve the remainder of his sentence,” Samour continued.

When he learned he was being released, Lima-Marin called his wife to tell her the news.

“It was a really, really fast call. He said, ‘Did you hear?’ And I was like, ‘Yeah,’ and I could just hear his smile,” Lima-Marin's wife, Jasmine, told KCNC.

Jasmine and their two children bought balloons and hung banners in anticipation of the family’s reunion, but Lima-Marin never showed up.

Lima-Marin was moved to the Denver Reception and Diagnostic Center where a Criminal Justice Information Services review had determined he might have an ICE detainer. The detainer was later confirmed, according to a statement from the Colorado Department of Corrections obtained by the Denver Post.

“We’re just still waiting and trying to figure out what’s going on and how to fight,” Jasmine told the Denver Post.

Lima-Marin was brought to the US when he was two years old by his parents, who fled from Cuba during the 1980 Mariel boatlift, according to the Denver Post.

When his parents arrived, they both applied for citizenship, but they never went through the process for their son. However, Lima-Marin’s father, Eli Borges, said that his son became a legal resident when they arrived in the US.

“We’re going to do everything we can to avoid that, if that’s possible. We’re obviously all completely devastated by the news but working hard to see what there is to be done. We’re going to attack this from every angle possible.”

Since he was convicted of an aggravated felony, Lima-Marin would eligible for deportation if his legal status is not upheld, according to the American Immigration Council.