OAKLAND, Calif.—A judge in Northern California on Friday freed a man who spent nearly seven years behind bars after being wrongfully convicted for attempted murder.

Ronald Ross broke down and began sobbing for 10 minutes after Alameda County Superior Court Judge Jon Rolefson ordered his release. A team of volunteer lawyers argued for four years that Ross was a victim of sloppy police work and lies by witnesses.

"Congratulations, Mr. Ross," said the judge who told the 51-year-old man that the justice system had failed him for a while. "(But) the important thing is that in the final process, justice is achieved."

Moments after the order was made, the judge allowed Ross' 77-year-old mother, Thelma, to hug her son for the first time since his arrest. Using her cane, she walked slowly over to the defense table for a long, emotional embrace.

"Oh, Lord. Oh, Lord," cried Thelma Ross as she hugged her son. "Thank you, Jesus. Thank you, Jesus."

Hours later, Ross walked away a free man. He had been serving a 25-years to life prison sentence for his alleged role in the 2006 shooting of Renardo Williams, a neighbor of his mother in Oakland.

After Ross lost his appeal in 2008, the Northern California Innocence Project at Santa Clara University and the San Francisco law firm Keker and Van Nest began investigating his case and eventually got his release.

"God blessed me with the Dream Team, Angels that brought me this far," Ross told reporters about his legal team after his release. "Without them I would probably be stuck behind these walls for something I had not done."

Ross became the primary suspect in the case after a former Oakland police sergeant placed his photo in a lineup, and Williams wrongly identified Ross as the man who shot him.

Williams told police that he believed he had been shot as a result of a previous dispute with a 14-year-old boy and his mother. He said the boy had been with the gunman, who he believed was the boy's father.

But the investigating officer testified that he had put a picture of Ross—not of the boy's father —in a photo lineup that he showed to Williams as he lay wounded at Highland Hospital.

Ross' photo was included in the lineup because his mother was Williams' neighbor 10 years before the shooting. Court documents indicate the officer placed Ross' photo in the lineup to fill a spot and because he had a past criminal record for minor drug offenses.

But when Williams selected Ross' photo three days after the shooting, while lying in the hospital bed with an intravenous morphine drip, the officer disregarded other evidence and focused his investigation on the innocent man, court documents say.

The officer soon retired after the shooting.

Ultimately, attorneys said, Williams and the boy recanted their identifications of Ross, while new evidence showed the third witness hadn't actually been in a position to see the shooting.

County prosecutors eventually agreed to drop charges against Ross and requested his release from prison.

The boy's father is now in jail, accused of an Oakland crime spree in July 2011. Prosecutors have no plans to charge him with shooting Williams.

Oakland police say they are reopening the original investigation into the shooting.