The ex-New Jersey superintendent outed as the school’s “mystery pooper” may have defecated on campus grounds — but law enforcement were the ones that leaked, he claims in a new lawsuit.

Thomas W. Tramaglini — a former head of Kenilworth Public Schools — filed a federal lawsuit Tuesday against the township of Holmdel, claiming police gave his mugshot to news outlets before he was criminally charged.

The 43-year-old — who was dubbed the “Pooperintendent of Schools” — pleaded guilty in October to relieving himself under the bleachers near the Holmdel High School athletic field.

When he was busted, Tramaglini faced lesser charges of littering and public defecation, which wouldn’t have warranted authorities booking him, according to the lawsuit.

But his attorney alleges law enforcement plotted to “harm and damage” the school head by leaking his booking photo.

It’s not clear who they conspired with over the defecation scandal, but his mugshot was later cited by the school board as a “basis for parting ways” with him.

“Tramaglini will never achieve the level of compensation, benefits, and retirement pension income that he otherwise [would] if the unlawfully taken photographs of him had not been released into the media to satisfy the prurient interests of certain members of Holmdel Township Police Department and others they conspired with,” the lawsuit states.

In the lawsuit, Tramaglini lashes out at local media outlets such as NJ.com, claiming the site’s director of news, Christopher Kelly, told his staff to “have some fun” with the mystery pooper coverage.

“[Tramaglini] was forced to step down from his position as Superintendent of the Kenilworth Public Schools, ending his twenty-year career in public education, even before a disposition of the charges he faced, due to the negative media attention his case received,” the suit states.

The suit — which also names school resource officer, Jonathan C. Martin, and Holmdel Police Chief John Mioduszewski — is seeking unspecified damages.