The NYPD’s gun license division was so corrupt they OK’d a pistol permit to a Brooklyn maraschino cherry manufacturer who had been arrested for domestic assault — and the businessman later killed himself with his handgun, jurors heard Wednesday.

Arthur Mondella’s gun license should have been revoked in 2011 — years before his 2015 suicide in a bathroom of his Red Hook plant during a days-long raid of his Dell’s Maraschino Cherries by the Brooklyn District Attorney’s office, a witness testified in Manhattan federal court.

Officers with the NYPD’s License Division recommended that Mondella’s gun license be pulled after they were alerted to his July 2011 domestic assault arrest, ex-NYPD Sgt. David Villanueva testified at the guns-for-bribes trial of lawyer John Chambers.

But Villanueva, a supervisor in the gun license division, overrode the revocation because he was being bribed by Chambers, Mondella’s lawyer, he told the jury.

“Why did you do that?” Manhattan federal prosecutor Paul Monteleoni asked Villanueva about Mondella’s gun license.

“Once again, it was John Chambers’ case,” said the disgraced sergeant, who has pleaded guilty and is cooperating with the feds.

Chambers, 63, is on trial for bribing Villanueva, 44, with a slew of lavish gifts over the years in exchange for gun permits for people who should not have had them, including Mondella.

Villanueva said he also OK’d a license for Vladimir Gotlibovsky who famously shot a woman at a million-dollar wedding at the Waldorf in 2015.

The wedding fiasco, which resulted in criminal charges, wasn’t mentioned at trial. But Villanueva testified that his team suggested the NYPD pull Gotlibovsky’s gun license after he shot himself in his own foot on Christmas Eve, just a few months later.

Villanueva nevertheless OK’d Gotlibovsky for a license continuation because Chambers was his lawyer, he said.

Gotlibovsky, reached through a lawyer, didn’t immediately return a request for comment.

Other clients Villanueva helped because he was getting bribed by Chambers included martial artist Feilong Qi — a two-time contestant on “America’s Got Talent” — who was also under investigation for a “domestic incident,” Villanueva said.

Reached by phone, Qi said he used Chambers as a lawyer and called him a “friend.” But he said he didn’t know about the bribe allegations. “I don’t know anything about that,” he said.

On cross examination, Villanueva also admitted to helping a man he believed was associated with organized crime secure gun upgrades for people with Nassau County gun permits that then allowed these people to bring their weapons into NYC.

“Were you concerned that the guns provided … were being used for criminal activity?” Chambers’ defense lawyer asked Villanueva on cross-examination. Villanueva never directly answered the question.

On Wednesday, the ex-sergeant said the license division was a mess from top to bottom — starting with his former boss, Deputy Inspector Mike Endall, who rubber-stamped all of Villanueva’s questionable approvals.

“All of these cases I always consulted with Captain Endall. He would always say, ‘make it happen,’” Villanueva said.

Endall, who is no longer with the NYPD, did not return a request for comment.

The trial continues Thursday.