The ex-wife of Guardian Angels founder Curtis Sliwa discovered he was a devil of a husband when she listened in to X-rated cell phone voicemails to him from his alleged mistress, Queens Borough President-elect Melinda Katz, her attorney said Wednesday.

“Curtis is not street smart, he was street dumb,” quipped Mary Sliwa’s attorney Paul Siegert outside Family Court, where the parties earlier battled over Sliwa’s demand that his child support payments be lowered.

“He gave her the code and forgot.”

Mary, Sliwa’s third ex-wife, was the Guardian Angels’ executive director during her marriage to the law-and-order legend.

She had her husband’s voicemail password so that she could handle calls for the organization, Siegert said in court.

Mary “was also privy to telephone messages from Melinda Katz to Curtis Sliwa that were coming in constantly over long periods of time,” he told Magistrate Margaret Morgan.

“They deny any relationship at all prior to 2011. That’s not true,” Siegert said.

He was barred by Morgan from asking Mary or Katz, a former Queens assemblywoman and councilwoman, about details of the alleged affair, but he revealed the information to reporters after the proceeding.

Siegert promised that emails and voice recordings from Katz to Sliwa spanning from December 2009 to July 2010 will come out in a separate action filed by Mary Sliwa in Manhattan Supreme Court last May.

That suit documents 13 instances during Mary and Curtis’ marriage when her husband allegedly abandoned his marital bed and engaged in “sexual intercourse” with Katz, the court papers claim.

Sliwa separated from Mary and moved in with Katz in the spring of 2011.

Siegert gave a sneak-peak into the evidence: “It was sex, it was money. It was her being a mistress. It was him calling at 2 a.m,” he said.

The voicemails allegedly match descriptions of infidelity in the Manhattan Supreme Court suit. The first romp allegedly took place at Katz’s Forest Hills home on Feb. 25, 2010.

The illicit lovers allegedly continued meeting at the Queens home where the politician grew up, with Sliwa fibbing to his wife on March 31, 2010 that “he wasn’t feeling well and was dehydrated” and would sleep at his Empire State Building office.

Then on June 5, 2010, Sliwa allegedly claimed he “would be going to the big fight night at Yankee Stadium” even though he didn’t come home until 3:30am, according to the suit.

The parties are in court because Sliwa filed a lawsuit to slash the child support he pays to Mary from $13,000 to $2,500 following a reduction of his salary.

His live-in girlfriend took the stand on Wednesday.

Siegert called Katz a “hostile witness” as she snapped short answers, mostly of the “I don’t remember” variety.

While Katz was reluctantly testifying Sliwa sat across the courtroom with his head buried in his hands.

Katz and Sliwa have two young boys, whom she conceived through in-vitro fertilization with his sperm.

Siegert plans to subpoena Katz’s bank records after she testified that she receives only $5,000 a month in child support from Curtis. He told the court on Monday that he pays her $10,000.

Sliwa told The Post outside court that he did not remember Mary listening to his calls and noted, “There was a divorce that was not contested.”

Katz, who left the courtroom ahead of the Guardian Angels founder, said only, “It’s a personal matter.”