Image copyright Courtesy Jasmine Lima-Marin Image caption Rene Lima-Marin fought for three years to win his release, but is now in the custody of Ice

After a massive procedural mistake and a three-year fight for his freedom, Rene Lima-Marin was set to be released from a Colorado prison this week. Instead, he is now in US Immigration and Customs Enforcement custody, facing deportation.

At first, Jasmine Lima-Marin did not want to tell her two boys that their father was coming home until he physically walked through the door. But after a Colorado judge issued a scathing, 165-page decision ordering his release, reporters, family and well-wishers started calling and dropping off bunches of balloons for the impending homecoming. It became impossible to keep the secret.

"They were really excited," she says.

But it now appears that her first instinct was correct. Before Lima-Martin could set foot outside, agents from US Immigration and Customs Enforcement (ICE) arrived to take the 38-year-old father into custody on Wednesday. He now faces deportation to Cuba.

Instead of welcoming her husband home, Jasmine spent the night rallying with supporters outside of an Ice detention centre.

"It feels very political to us," says Jaime Halscott, the lawyer who argued for Lima-Marin's release earlier this year.

"Ice didn't seem to want to do anything with him for years, they didn't do anything. They didn't take any action on it. Now that the Department of Corrections and the state has egg on their face, someone's still got to pay. That's what it feels like."

Lima-Marin was a baby when his parents brought him to the US from Cuba during the 1980 Mariel boatlift. Lima-Marin grew up into a troubled teenager who burglarised cars for extra cash.

When he was 19, he committed two video store burglaries with a friend, armed with a rifle. They were caught almost immediately. In 2000, Lima-Marin was sentenced to 98 years in prison.

This was also when he was ordered removed from the country by a federal immigration judge.

After 10 years behind bars, Lima-Marin was paroled and released by accident in 2008 - 88 years early. An apparent clerical error caused officials at the Colorado Department of Corrections to believe he was serving concurrent, not consecutive, years on his sentence.

"I had no clue as to how any of this works," Lima-Marin testified at a hearing for his release. "All I knew was, my prayers had been answered."

He walked out of prison at the age of 29 a seemingly changed man. He had no more run-ins with law enforcement, he married his long-time girlfriend Jasmine, and they started a family. They had two boys, Justus and Josiah, bought a house. Lima-Marin was working as a glazier, installing glass on downtown Denver skyscrapers.

He kept his record spotless for nearly six years and according to his wife Jasmine, had regular check-ins with immigration officials and his parole officer.

But in 2014, the prosecutor who sent him to prison happened to look Lima-Marin up, and was shocked to see he was free. Officers came to Lima-Marin's home that night to re-arrest him.

Image copyright Courtesy Jasmine Lima-Marin

Lima-Marin has been fighting for his release ever since, on several fronts. State legislators unanimously passed a resolution urging the Colorado governor to grant Lima-Marin clemency. His lawyers drew up a writ of habeas corpus, and argued in front of Judge Carlos Samour for his release in a December 2016 hearing.

On Tuesday this week, Samour released his lengthy decision that ordered Lima-Marin's immediate release.

"It would be utterly unjust to compel Lima-Marin, at this juncture, to serve the rest of his extremely long sentence," he wrote. "The government - not Lima-Marin, his family, the community, and society - should bear the brunt of the consequences of its conscience-shocking deliberate indifference."

Jasmine Lima-Marin spent all day Wednesday waiting to find out when she could make the short drive to pick up her husband. During the three years they have been apart, she has struggled to keep their home out of foreclosure, and to buoy the spirits of her children.

Now that struggle continues.

"It's terrible. Unexpected. I was shocked," says Jasmine. "I told [the kids]. I don't think they really understand what's going on."

Dave Williams, the Colorado Republican who sponsored the resolution to grant Lima-Marin clemency, issued a statement expressing outrage over the arrest.

"The injustice committed by our Colorado criminal justice system and Rene's remarkable story of redemption, as outlined in Judge Samour's decision to release him, should not be disregarded simply because Ice has decided to step in," he wrote.

"When Rene was a baby, his parents took him and left an oppressive Cuba. They were all granted permission to stay here and experience the freedom that the United States had to offer."

Questions remain about Lima-Marin's immigration status, which seems to have been affected not only by the new presidential administration but by shifting Cuba-US policies. Kimberly Diego, another of Lima-Marin's lawyers, says that because of the Cuban Adjustment Act, he was a lawful permanent resident. She says he had been under an order of supervision from Ice and was compliant with all of their conditions.

Under the Trump administration, many undocumented immigrants that were not priorities for removal under the previous administration are being arrested and deported. The latest figures show that immigrant arrests are up 38% from the same time period in 2016.

"These new days it's apparently a lot cooler to just grab everybody and throw them out of the country," says Halscott.

Image copyright Getty Images Image caption Advocates are hoping that Colorado Governor John Hickenlooper will grant Lima-Marin a pardon

He says Rene now has an immigration lawyer and will be fighting deportation. There is also still an open application for a pardon on Governor John Hickenlooper's desk, which - if granted - could halt Lima-Marin's removal.

Hickenlooper issued a statement about Lima-Marin's surprise detention, but did not address the issue of a pardon, or return requests for comment from BBC News.

"We can't imagine the emotional roller coaster this family has endured," Hickenlooper wrote. "The family has shown amazing strength and we hope this is a temporary stop on his way to being reunited with his family."