To screams of joy and applause, a 41-year-old man who spent 20 years behind bars for crimes he did not commit was set free Tuesday after a judge found he had been wrongfully convicted.

Marco Contreras, 41, beamed and clasped his hands above his head in a downtown Los Angeles courtroom after Superior Court Judge William Ryan reversed his conviction on attempted murder and robbery charges from a case stemming back to 1996.

Contreras said justice was served, even if it was slow, but he's not angry. He said he's looking forward to having a home-cooked meal.

"I am glad that the DA ... they did their part as far as making this happen," Contreras said after the judge told him he could go home in a courtroom crowded with more than a dozen family members and friends. "I would like to thank everyone that partook in making this happen."

An eyewitness misidentified him as the assailant during a 1996 attempted robbery and shooting that severely wounded a man at a gas station in Compton.

Lawyers at the Project for the Innocent, at Loyola Law School, and the Los Angeles County District Attorney's Office Conviction Review Unit filed a petition for Contreras to be released.

"We are thrilled and our client is thrilled. It's been 20 long years," said Loyola law professor Laurie Levenson, who founded Project for the Innocent and has represented Contreras since 2012. "Thankfully this is a case that the District Attorney's Office was committed to getting right."

Contreras was convicted in 1997, said Robert Grace, who heads the DA's Conviction Review Unit.

His conviction came after an eyewitness inaccurately identified him as the assailant, his lawyers said.

Contreras has maintained his innocence from the beginning and fought to have his case re-investigated.

In 2014, the Project for the Innocent took up his case. By the end of that year the District Attorney's Office and the LA County Sheriff's Department were reviewing the case.

Three other men were charged in the case last week, after Contreras was found innocent of the crime, Grace said.

The Sept. 10, 1996 shooting severely wounded Jose Garcia while he was pumping gas. Garcia spent 23 days in the hospital and survived the shooting.

A witness, who was stopped at a red light across the street from the gas station, said she heard a gunshot and saw the victim run through the gas station being chased by a man with a gun. She identified the getaway vehicle, got the vehicle's license plate number and reported it to authorities.

The truck was registered to Marco Contreras and he was misidentified as the shooter.

Two years later, another witness came forward saying Contreras was not the gunman.

In July 1998, the detective on the case submitted a statement stating that he believed another individual was the gunman, Loyola Law School lawyers said.