A judge dismissed the murder charge against Gregory Elarms on Tuesday. Elarms was the prime suspect in the June 2010 fatal shooting of David Lewis outside Hillsdale Shopping Center.
Police allegedly obtained a confession from Elarms illegally, the judge said.
Elarms, who pleaded not guilty to the murder last month, had previously been found incompetent to stand trial and was even sent to a state hospital following his arrest.
He remains in custody on an unrelated charge while the San Mateo County District Attorney's office weighs whether to refile the murder charge or appeal the judge's decision.
Elarms is suspected of following Lewis -- whom he knew from growing up in East Palo Alto -- from the San Mateo Medical Center to the nearby Hillsdale Mall on the evening of June 9, 2010, and then shooting him once in the stomach with a .44-caliber handgun.