At 22, Alvin Kennard was sentenced to life in prison without the possibility of parole. His crime? Stealing $50.75.

Now 58, Kennard is coming home after spending more than 35 years — virtually his entire adult life — behind bars.

On Wednesday, when an Alabama judge ordered that he be released from prison, more than a dozen friends and relatives leapt to their feet and cheered. His niece Patricia Jones told WBRC, "I just threw my hands up and said, 'God, I thank you, I thank you.' "

The unusually harsh punishment was the result of Alabama's Habitual Felony Offender Act, also known as the "three strikes law," which was intended to crack down on repeat offenders when it was enacted in the 1970s. But Kennard wasn't exactly a hardened career criminal when he was sentenced to life: His record consisted of being charged in connection with a break-in at an unoccupied gas station when he was 18, for which he was put on probation for three years, AL.com reported.

Several years later, Kennard and another man walked into the Highlands Bakery in Bessemer, Ala., wielding a knife, and emptied the cash register, court records said. In 1984, Kennard was convicted of first-degree robbery. Because he had pleaded guilty to three felony counts in the gas station break-in, the penalty was a mandatory life sentence.

Kennard was incarcerated in Bessemer, where his family lives, so for more than three decades, they were able to visit him regularly. Jones told WIAT that she had seen firsthand how prison made him a different person. After a few years behind bars, "he started talking about God and I knew he had changed," she said. "He wants to be forgiven for what he had done and he wants the opportunity to come back."

His family prayed he would be released one day, knowing that the odds were against him. Then, in 2013, faced with overcrowding in the prison system, Alabama began to rethink its sentencing guidelines and gave judges more discretion in cases like his. If Kennard were sentenced for first-degree robbery today, AL.com said, he would still be eligible for life with the possibility of parole, but the minimum sentence would be 10 years in prison.

The Alabama Appleseed Center for Law and Justice, a nonprofit legal advocacy group, took up Kennard's case. The group noted that he had been an exemplary inmate who lived in the "honor dorm" — where prisoners are subject to stricter rules — and hadn't been cited for an infraction in more than a decade.

Carla Crowder, the organization's executive director and Kennard's attorney, argued in court that he would likely have been eligible for parole 20 years ago if he had been sentenced under the new standards, WIAT reported. She pointed to Kennard's friends and family in the courtroom as proof that he had an unusually strong support system.

Kennard told the judge that he deeply regretted the crimes he committed more than three decades ago, and, if released, hoped to work as a carpenter. "I just want to say I'm sorry for what I did," he said, according to WIAT. "I take responsibility for what I did in the past. I want the opportunity to get it right."

Prosecutors did not oppose the motion to shorten Kennard's sentence, AL.com reported, and Circuit Judge David Carpenter resentenced Kennard to time served, meaning that he will be released as soon as the necessary paperwork is completed.