A federal judge on Tuesday overturned the misdemeanor child endangerment conviction of Graham Spanier, the former president of Penn State, for his actions in the Jerry Sandusky scandal, one day before Mr. Spanier was scheduled to report for a two-month prison term.

The ruling, reported by The Associated Press, represented a setback for prosecutors taking the rare step of holding a university leader, and one at such a prominent institution, criminally liable for the misconduct of others.

In this case, prosecutors sought to punish Mr. Spanier for failing to go to law enforcement when he learned that Mr. Sandusky, an assistant coach of the vaunted Nittany Lions, was seen abusing a boy in a locker room shower on campus.

Magistrate Judge Karoline Mehalchick, reversing two lower court rulings in Mr. Spanier’s appeal of his conviction, wrote in her decision that prosecutors incorrectly applied an expanded child endangerment statute to Mr. Spanier. Prosecutors have three months to retry the case, the judge said in her ruling, according to The Associated Press.