A prominent New Jersey educator lost his job, his wife, his mind and possibly his freedom — thanks to the Ashley Madison hack, The Post has learned.

David Browne, district school superintendent of Randolph, NJ, sustained severe burns while trying to torch his garage after confessing to his wife and school board he had an account with the infamous infidelity website.

His admission came after Ashley Madison was hacked and its 32 million patrons saw their dirty little secrets exposed to the world on Aug. 20, a source familiar with the case said.

Weeks later, Browne, 55, took a medical leave of absence and was replaced by an acting superintendent on Sept. 8.

But it was the blaze and personal meltdown on Oct. 13 that sent shockwaves through Randolph and Browne’s hometown of Wyckoff.

Rescuers responded to 380 Wyckoff Ave. at about 2:45 p.m. to find the detached garage engulfed in flames. Browne was lying outside, “suffering from numerous injuries,” according to Bergen County Prosecutor John Molinelli. Browne had used an accelerant to start the blaze, authorities said.

The downward spiral accelerated. On the same day as the suspected arson, Browne was placed on paid administrative leave.

Two weeks later, on Oct. 27, he resigned from his $167,500-a-year job as school boss. Officials said, “It was in the best interest of both parties to end the employment relationship.”

It appears he was pressured to quit because his online antics were linked to a “work-issued device,” a source said.

On Nov. 4, Browne was charged with arson. And on Nov. 23 — his 14th wedding anniversary — his wife, Monica, the superintendent in Upper Saddle River, filed for divorce.

Cops, firefighters and education officials were tight-lipped last week, refusing to comment on neighbors’ online statements that Browne superficially slit his wrists before starting the blaze in his historic, circa-1737 home.

In announcing Browne’s departure in October, school board president Tammy MacKay would only say he was quitting “for the purpose of retirement” and would collect three months of severance.

She declined to elaborate last week, citing non-disclosure laws. Browne had been superintendent of the 4,900-student district since July 2011.

A source familiar with the melodrama told The Post that Browne “had an Ashley Madison account” and “self-reported to both his wife and the board of ed.”

David and Monica Browne, 45, did not return multiple messages seeking comment.

“I hope everybody understands that this is a family with two young children in a small community — and they deserve their privacy,” said Robert Landel, Monica Browne’s divorce attorney.

Craig Swenson, David Browne’s criminal defense lawyer, said he is not yet privy to material such as police reports or statements his client may have made to authorities.

Swenson said Browne was released from Hackensack University Medical Center and hasn’t been back to his house.

“I can tell you Mr. Browne did not expect a divorce complaint to be filed,” Swenson said on Friday.

The wife’s divorce filing cites “irreconcilable differences . . . which have caused a total breakdown of the marriage” but does not detail them.

Monica Browne is seeking custody of the couple’s 10- and 12-year-old kids.

The Ashley Madison cyber-attack and subsequent leak of account holders’ email addresses have ruined lives. Millions of ex-clients, many of whom said they had accounts but never actually hooked up, have been blackmailed by online thugs threatening to alert spouses, friends and co-workers to adulterous activity.