An Oklahoma judge has exonerated a man who spent 48 years in prison for a murder he didn't commit, the longest known wrongful sentence in the US.

Glynn Simmons, 70, was freed in July after a district court found that crucial evidence in his case was not turned over to his defence lawyers.

On Monday, a county district attorney said there was not enough evidence to warrant a new trial.

In an order on Tuesday, Judge Amy Palumbo declared Mr Simmons innocent.

"This court finds by clear and convincing evidence that the offence for which Mr Simmons was convicted, sentenced and imprisoned... was not committed by Mr Simmons," said Oklahoma County District Judge Palumbo in her ruling.

"It's a lesson in resilience and tenacity," Mr Simmons told reporters after the decision, according to the Associated Press. "Don't let nobody tell you that it can't happen, because it really can."

Mr Simmons served 48 years, one month and 18 days in prison for the 1974 murder of Carolyn Sue Rogers during a liquor store robbery in an Oklahoma City suburb.

He was 22 years old when he and a co-defendant, Don Roberts, were convicted and sentenced to death in 1975.

The punishments were later reduced to life in prison because of US Supreme Court rulings on the death penalty.

Mr Simmons had maintained his innocence, saying he was in his home state of Louisiana at the time of the murder.

Mr Simmons smiled as the court declared his innocence on Tuesday. Dressed in a grey hooded sweater and fedora, a soft-spoken Mr Simmons later told reporters he had been waiting for this moment for a "long, long time".

"What's been done can't be undone, but there can be accountability," he said.

Asked to describe his emotional state, his lawyer Joseph Norwood told BBC News: "Obviously elation."

"The thought of being confined in prison for 50 years for something you had nothing to do with has to just be one of the worst things for a person's mental state," Mr Norwood said in an interview on Thursday.

But Mr Simmons was diagnosed with stage four cancer as he was being released, says the attorney.

"So it was a mix of elation, gaining his freedom, gaining his name back, clearing his name," said Mr Norwood, adding that Mr Simmons was now responding well to chemotherapy and was "on the mend".

"So it's been a heck of a ride."

Mr Simmons is currently battling liver cancer, according to his GoFundMe, which has raised almost $200,000 (£157,000) to help support his living costs and medical treatment.

A district court vacated his sentence in July after finding that prosecutors had not turned over all evidence to defence lawyers, including that a witness had identified other suspects.

Mr Simmons and Mr Roberts were convicted in part because of testimony from a teenager who had been shot in the back of the head. The teenager pointed to several other men during police line-ups and later contradicted some of her own testimony, the National Registry of Exonerations said.

Mr Roberts was released on parole in 2008.

Wrongfully convicted people who serve time in Oklahoma are eligible for up to $175,000 in compensation.