A depraved British principal busted for ripping off tens of thousands of dollars from his school kept a secret sex lair inside his office, stocking it with a tawdry array of adult toys and booze, a court heard at his sentencing this week.

James Stewart, the principal and headteacher of Sawtry Village Academy for almost 30 years, was sentenced to four years in prison Thursday after pleading guilty last year to fraud, and misuse of office — for canoodling with his married assistant on campus, drinking during the day, and taking ski breaks and racing trips.

Witnesses at his trial said they would hear suspicious noises emanating from the “dungeon” he crafted in his inner office, including “rhythmic moaning and banging.”

One witness said he heard the principal chasing his mistress around the office to “Benny Hill Show-like music,” the Daily Mail reported.

The two were also seen “in a disheveled state with red wine stains around their mouths,” the Cambridge News reported.

Stewart’s office had a series of rooms that were lined with custom-made oak and glass shelving, furniture and doors, which were installed while the school went without inspections for asbestos and other checks.

Behind those doors, police found shelves of booze, a minifridge stocked with wine, adult toys — including a large purple vibrator — along with sex games, watermelon lubricant, condoms, a large packet of penis straws and coasters with scenes from the Karma Sutra on them. There were piles of cushions that might be spread on the floor like a bed. Two more vibrators were found in a desk drawer, officials said.

The principal, now 72, spent some $7,500 on hotel stays in London, during which he bought the adult toys, all paid for on his school credit card. He also racked up bills totaling about $65,000 on food and drink, including alcohol, in restaurants near his home, and ran up $14,000 in charges on electronics, including at least three TVs, DVD players, cameras and laptops, officials said. School funds were also used to pay personal expenses like car insurance and newspaper and magazine subscriptions.

When he was at the school, Stewart was often holed up in his office, and regularly drank heavily during the school day. He also frequently left the school to watch horse racing and to take ski trips, some of which were charged to the school.

Stewart, nabbed in 2014 after whistleblowing staff members reported his seedy conduct to British education authorities, has so far repaid the school about $100,000 of the $162,000 he ripped off.

Ex-vice principal Alan Stevens, 66, also admitted fraud after he was found to have hit the school with bogus expense and credit card claims worth about $600. He was sentenced to 24 weeks in prison, but it was suspended for 12 months.

The school was left in a “dire financial” position by the fraud, and had lost staff and was placed under special supervision by the time Stewart’s exploits were uncovered in 2014.