The decision came a year after the Supreme Court of Canada unanimously decided Leighton Hay should get a new trial based on new hair evidence.
As Hay and family members looked on, Superior Court Justice John McMahon apologized that it took so long for the system to get it right.
Hay, who has a mental illness and spent most of his incarceration in the psychiatric wings of two penitentiaries, did not speak as he left court but his supporters did.
"He's out, he's free," an excited Win Wahrer of the Association in Defence of the Wrongly Convicted said minutes after the brief hearing. "He just wants to go home."
In an interview, lawyer James Lockyer said he wasn't sure his client was able to process the implications of what had just occurred.
"Leighton has been through a nightmare for all these years," Lockyer said. "This was a miscarriage of justice of the highest order."
As a teen with mental-health problems and a member of a visible minority, the lawyer said, Hay was "vulnerable" and police rushed to judgment.
"He was another black guy," Lockyer said.
Hay was arrested after two men burst into a fundraiser at a Toronto nightclub in July 2002 and gunned down a respected community figure, Colin Moore, over a disputed cover charge.
The identity of one of the shooters, Gary Eunick, was never in doubt and he was convicted and sentenced to life in prison.
The Crown alleged Hay, then 19, was Eunick's dreadlocked accomplice. The only problem was Hay's hair was almost completely shorn when police arrested him.
At his trial in 2004, prosecutors argued Hay had rushed home and shaved his scalp to get rid of his dreadlocks after the shooting.
Key evidence in support of the prosecution theory was hair found in a newspaper in his bathroom garbage and in the electric razor on his nightstand.
The one witness who fingered Hay had pointed to his image in a photo line-up, saying he looked more like the second gunman than the other 11. She was shown a second line-up three weeks later and did not choose Hay, who always denied any part in the killing.
Nevertheless, the jury convicted him of first-degree murder.
The association for the wrongly convicted became involved after Ontario's top court rejected his appeal.
At the association's request, forensic experts determined the hair used to convict Hay did not come from his scalp but from his face. The finding undercut the Crown's contention he had cut off his dreads to alter his appearance.
Last November, the Supreme Court of Canada heard the new hair evidence. The court concluded the information could have made a crucial difference at Hay's trial and quashed his conviction.
The Crown announced Friday it would not proceed against him.
Hay's father said he appreciated the judge's apology and always believed justice would ultimately be done.
"He lose 12 years," Lascelles Hay said. "I hope a lot of good things for him."
Hay's mental health declined in custody, but Lockyer said he was "guardedly optimistic" Hay would manage as a free man living with family.