Pennsylvania Attorney General Josh Shapiro vowed Wednesday to appeal what he described as a “last-minute and highly unusual” ruling that overturned Graham B. Spanier’s child-endangerment conviction just hours before the former Pennsylvania State University president was scheduled to report to jail.

In a statement, the state’s top prosecutor said his office would ask the U.S. Court of Appeals for the Third Circuit in Philadelphia to review the decision.

He questioned the grounds on which Scranton-based U.S. Magistrate Judge Karoline Mehalchick intervened late Tuesday to spare Spanier from incarceration for his alleged mishandling of a 2001 claim that former Penn State assistant football coach Jerry Sandusky had sexually abused a boy.

“Federal courts have very limited power to act in state criminal proceedings,” Shapiro wrote. “This ruling plainly exceeded that power.”

Spanier, 70, had been ordered to report to jail Wednesday morning. In her ruling, Mehalchick concluded he had been improperly tried under a version of state child-endangerment laws that were not in place at the time of his alleged crime.

She gave prosecutors 90 days to retry the former university president under the law as it stood back then.

But an appeal from Shapiro’s office threatens to upend that timeline and fan the flames of a debate that has plagued the campus for nearly eight years.

Ardent Penn State supporters — including several of the school’s trustees — maintain that prosecutors, the media, and the Penn State board members rushed to judgment in an effort to appear responsive to Sandusky’s crimes.

Shapiro, who has staked his first term as Attorney General on prosecuting child sex abusers and their enablers described the evidence against Spanier as clear.

“Graham Spanier … was personally advised that children were being sexually abused on school property,” the statement read. “Evidence proved he chose not to help the children — but instead to cover up the abuse, despite being well aware of his responsibility as a supervisor.”

In their own statement Wednesday, Spanier’s lawyers accused Shapiro of misrepresenting the facts and described his prosecution as “overzealous and unlawful.”

“We are stunned that Mr. Shapiro accuses Dr. Spanier of engaging in a ‘cover-up,’ when a jury expressly acquitted Dr. Spanier of having engaged in a conspiracy or a continuing course of conduct,” said the lawyers, Samuel W. Silver and Bruce P. Merenstein.

Spanier was convicted in 2017 on a misdemeanor count of child endangerment tied to his failure to adequately respond to the 2001 complaint from then-graduate student Mike McQueary. Jurors found him not guilty on other counts alleging conspiracy.

McQueary has said he reported that he saw Sandusky abusing a boy in a locker-room shower, though Spanier maintains what was described to him was nothing more than horseplay.

The former university president and two top aides — former Penn State athletic director Tim Curley and ex-university vice president Gary Schultz — agreed to notify the Second Mile, Sandusky’s charity for at-risk youth and the source of many of the ex-football coach’s victims, and to bar Sandusky from bringing boys onto campus.

But they did not report McQueary’s complaint to authorities.

Mehalchick, a Penn State grad, found in her ruling Tuesday that state law at the time required only “a parent, guardian or other person supervising the welfare of children” to report suspected abuse and that Spanier could not have reasonably foreseen in 2001 that he would have been included under that statute.

The law was revised in 2007 to also include people that “employ or supervise such a person” — a category Dauphin County Court Judge John Boccabella mentioned when instructing the jury on the law at the conclusion of Spanier’s trial.

In doing so, Mehalchick wrote, Boccabella violated the university president’s constitutional protections against being charged with laws that were not in place at the time.

Prosecutors maintain — and will likely argue on appeal — that the 2007 revision did not change the law but only clarified a category of mandatory reporter that had been inherently included before.

Once ranked among the most well-respected, highest paid, and longest-serving university presidents, Spanier was ousted from his post in the days after Sandusky’s arrest in 2011. He has said he regrets not acting more forcefully at the time of the McQueary complaint.

Curley and Schultz both pleaded guilty to misdemeanor child endangerment charges and testified as government witnesses in Spanier’s case. Both have since served jail terms and waived their appellate rights as part of their plea agreement with the government.

Sandusky is serving a 30- to 60-year sentence at a state prison in Somerset County.