A federal judge ruled Wednesday that the former head of a government whistle-blower protection office may withdraw a guilty plea because he had not been aware that the offense required a sentence of jail time.

Scott J. Bloch pleaded guilty in April 2010 to criminal contempt of Congress, admitting that he withheld information from investigators about ordering private technicians to scrub computer files at the Office of Special Counsel. He and prosecutors agreed in a plea deal that he could be sentenced to between zero and six months in jail. But neither side seemed to realize the offense carried a minimum sentence of 30 days behind bars.

Once that was brought to his attention, Bloch tried to withdraw his plea. But his effort was denied by U.S. Magistrate Judge Deborah A. Robinson, and she sentenced Bloch to 30 days in jail.

Bloch appealed Robinson’s refusal to allow him to withdraw his plea to Chief U.S. District Judge Royce C. Lamberth. On Wednesday, Lamberth ruled that Robinson had erred and overturned her decision, clearing the way for Bloch to officially withdraw his plea.

The Office of Special Counsel protects federal employees from reprisals from whistle-blowing. Appointed to his post by President Bush, Bloch had a controversial tenure that ended with his removal from office in 2008.

Though others had pleaded guilty to the same offense and been sentenced to probation, Lamberth noted in his 13-page opinion that the statute was clear that the offense carried a minimum sentence of jail time. “This is, at bottom, a situation in which lawyers have fallen short,” Lamberth wrote.

Still, Lamberth added, Bloch should not be penalized for those mistakes because it was clear he would not have pleaded guilty if he thought he was guaranteed a jail sentence. “There is nothing to refute defendant’s assertion that he would not have pled guilty had he been informed that he faced a mandatory minimum sentence,” the judge wrote.

Federal prosecutors did not oppose Bloch’s efforts to withdraw the plea. Bloch may now go to trial or negotiate another plea deal.

William Miller, a spokesman for the U.S. Attorney’s Office for the District of Columbia, declined to comment because the case remains active.

“We are gratified by the Court’s ruling that adopted the arguments we advanced on behalf of Mr. Bloch,” said Bloch’s lawyer, William Sullivan, in an e-mail.

This item has been updated since it was first published.