OAKLAND -- A 51-year-old who spent almost seven years in prison for attempted murder was released from custody Friday after Santa Clara University law students and a powerful law firm proved his innocence.

Ronald Ross bowed his head and broke down in tears as Alameda County Superior Court Judge Jon Rolefson ordered him released in a hearing that ended an almost decadelong saga sparked by a sloppy Oakland Police Department investigation.

Moments after the order was made, Ross' mother, Thelma, was allowed to embrace her son for the first time since he was arrested in 2006.

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

"Today is a great day for justice," said Cookie Ridolfi, executive director of the Northern California Innocence Project at Santa Clara University.

Ross was sentenced to 25 years to life in prison on June 29, 2007, in the shooting of Renardo Williams, a onetime neighbor of Ross' mother.

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

Ross' photo was included in the lineup because his mother was Williams' neighbor 10 years before the shooting. Court documents indicate Lovell 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 a hospital bed with an intravenous morphine drip, Lovell disregarded other evidence and focused his investigation on the innocent man, court documents say.

Police focused on Ross despite other evidence that showed Williams might have been shot by the father of a teen who had gotten into a fight with Williams a day before the shooting.

Williams told police that the teen's mother had threatened him after the fight, saying "her man" was going to settle the score. In addition, Williams initially told police that he believed the teen's father was the shooter.

Had Lovell investigated that man, Steven Embrey Sr., he would have found a man with several serious and violent criminal convictions. In fact, court papers show that since 2006, Embrey committed numerous violent felonies and is now awaiting trial in an unrelated attempted murder case.

But with Lovell's focus on Ross, prosecutors built a case against him fueled by lying witnesses and the ignoring of discrepancies that also were not fully investigated by Ross' court-appointed defense attorney.

At least three witnesses lied to the jury during the trial, including the teen, Steven Embrey Jr., Williams and the teen's mother, Nikki Stuart. The younger Embrey and Williams both testified they were confident Ross was the shooter, and Stuart testified she hadn't seen the elder Embrey for months even though she had.

Also, Ross, who has below-average intelligence, testified during the trial that he was at home watching a basketball playoff game at the time of the shooting. However, there was no playoff game on at the time.

The Alameda County District Attorney's Office used that misstatement to argue to the jury that Ross was lying about where he was. Ross' defense attorney never presented evidence showing that Ross was most likely watching a Golden State Warriors regular season game, which was airing the night of the shooting.

After the verdict, Ross' defense attorney, Michael Berger, contacted the Innocence Project in hopes of finding help for his client. The project began investigating the case with help from the San Francisco law firm Keker & Van Nest.

The investigation, which began soon after Ross was sentenced, produced new evidence including sworn statements from the younger Embrey that he had lied during the trial and that his father was the shooter. The elder Embrey also gave a sworn statement blaming the shooting on another man and saying Ross was not involved.

Initially, the District Attorney's Office fought against Ross' release, but as more evidence began to trickle in, the office reversed course and agreed last week to seek Ross' release and drop charges against him.

Linda Starr, legal director for the Innocence Project, said the case shows the judicial system is imperfect and that defense attorneys and prosecutors need to remain diligent in ensuring all facts of a case are thoroughly investigated.

"The system let him down," Starr said. "It's a demonstration that we should act diligently at all times."