REDWOOD CITY -- The Pittsburg man who confessed to killing East Palo Alto activist David Lewis will have to serve about five months in jail while prosecutors appeal the dismissal of the murder charge against him.

Though Gregory Elarms, 60, was sentenced Tuesday to four years behind bars, with credit for good behavior and time already served, he'll actually be in jail until August, said District Attorney Steve Wagstaffe. The sentence imposed by San Mateo Superior Court Judge Craig Parsons stems from charges Elarms had homemade weapons while in jail awaiting trial on Lewis' 2010 slaying.

Defense attorney Jonathan McDougall didn't respond to an email seeking comment.

The weapons charges were the only thing keeping Elarms in police custody after San Mateo County Superior Court Judge Stephen Hall dismissed the murder charge against him in November. Hall said San Mateo police detectives violated Elarms' rights when they ignored his repeated requests for an attorney during questioning that resulted in a confession to the killing.

Rather than refile the murder charge without the confession, prosecutors opted to appeal Hall's ruling. The attorney general's office is handling the case and a decision is expected in the fall.

The sentencing Tuesday ended a brief controversy over the amount of time Elarms should serve for the weapons case. Elarms was released from jail in early February and remained free for three weeks because Parsons believed he'd already served almost the maximum sentence of four years.

That turned out to be wrong, with Parson noting that McDougall had mislead him, and Elarms was taken back into custody Feb. 26. He'll serve the rest of the sentence in San Mateo County jail.

Lewis was gunned down June 9, 2010, as he walked from his Honda in the parking lot behind Hillsdale Shopping Center in San Mateo. The case went unsolved for months until Elarms contacted police and told them he had information about the case. Police have never established a clear motive in the drug-treatment and AIDS-worker's death.

Contact Joshua Melvin at 650-348-4335. Follow him at Twitter.com/melvinreport.