Updated

Cornealious "Mike" Anderson spent 13 years free from prison due to a clerical error, then nearly a year behind bars when the mistake was caught. On Monday, he walked out of a southeast Missouri courtroom a free man again — this time with no need to look over his shoulder.

Mississippi County Associate Circuit Judge Terry Lynn Brown needed just a 10-minute hearing before ruling that he was giving Anderson credit for time served for all 4,794 days between his conviction and when he was arrested last year. The judge granted Anderson his immediate freedom.

Anderson, 37, left the courthouse with his wife and 3-year-old daughter on one arm, his grandmother on the other, tears in all of their eyes.

"Very happy," Anderson said as he climbed into a sport utility vehicle for the ride home to suburban St. Louis and a planned family celebration. "My faith has always been in God. I'm just so thankful. I just thank God for everybody."

Anderson was 23 when he was sentenced to 13 years in prison for his role in the robbery of a fast-food restaurant's assistant manager. He told The Associated Press last month that he waited, and even asked about going to prison, but the order never came.

In the years since his conviction, Anderson started his own construction-related businesses, married and had children. He also coached youth football and volunteered at his church in Webster Groves, Missouri.

At the hearing Monday, Anderson's attorney, Patrick Megaro, said Anderson remained out of prison through no fault of his own, and in the intervening years, turned his life around.

"He has been able to accomplish for himself what the criminal justice system does not accomplish in many situations," Megaro told the judge.

Brown agreed. He pointed out that Anderson's crime was serious, but acknowledged that he's a far different man now than he was then.

"You've been a good father," Brown said. "You've been a good husband. You've been a good taxpaying citizen of the state of Missouri.

"That leads me to believe that you are a good man and a changed man."

As the judge announced his decision, about 10 of Anderson's relatives broke out in sobs and cried. Some hugged and thanked God.

Anderson's plight drew international headlines last month. An online petition on change.org includes more than 35,000 signatures urging the state to set him free.

The release was met with virtually no resistance from the Missouri Attorney General's Office. Assistant Attorney General Michael Spillane told Brown the court should consider the seriousness of Anderson's crime, but also Anderson's behavior over the 13 years of his freedom and the impact that imprisonment would have on his family.

Attorney General Chris Koster said in a statement, "From the outset, I have proposed a solution that balances the seriousness of Mr. Anderson's crime with the mistake made by the criminal justice system and Mr. Anderson's lack of a criminal record over the past 13 years. Today's outcome appears to appropriately balance the facts as we understand them."

The judge said that rather than grant parole, Anderson would get credit for the entirety of the time he should have been in prison. The distinction is important because it means Anderson doesn't have to report to a parole agent.

Megaro lauded the state's understanding of an occurrence that is exceedingly rare.

"This was not an easy case," Megaro said. "I believe it teaches us that justice can be swift, justice can be harsh, but justice also can be merciful."

Anderson had never been convicted of a serious crime before the robbery. He was sentenced to 13 years in prison for the holdup, then told to wait for orders that would specify when and where he was to report to prison. But the orders never came. Anderson suspected his case had been overlooked and asked his former attorney what to do.

"Day by day, month by month, year by year, time passed, and they never picked me up," he said in an interview last month with The Associated Press.

A court filing by the Attorney General's Office said the mistake happened when a trial court clerk failed to inform the Missouri Supreme Court that Anderson was free on bond after his initial conviction.

So Anderson went about his life, never trying to conceal his whereabouts or identity. He married, divorced, married again. He raised three children of his own and a stepchild, owned and operated three construction businesses. He coached his son's youth football team in Webster Groves, and he ran the video operation at his church.

In July, Anderson's sentence was supposed to end. It was then that someone at the Missouri Department of Corrections realized he had never been put behind bars. Eight U.S. marshals arrived one morning at his home in a middle-class neighborhood and took him away. He was in prison by noon that day, and had remained behind bars until Monday.

The hearing was in Charleston, Missouri, because that's where Anderson had been imprisoned.

"Go home to your family, Mr. Anderson," Brown said after his ruling.