When he raped and sodomized his estranged wife in front of their 2-year-old son while threatening to kill her unless she told the child to watch, Mario Liberta must have figured he was just taking advantage of a marital exception in New York law.

As defined by Section 130.35 of the state penal code at the time of this 1981 attack in a Buffalo motel, rape was “sexual intercourse with a female by forcible compulsion.”

But “female” was defined only as “any female person who is not married to the actor.”

The actor in this instance was a 23-year-old monster. And 23-year-old Denise Liberta had the misfortune of being his wife.

The exception when it came to wives in New York and other states was founded on a principle voiced by a 17th-century jurist named Lord Matthew Hale.

Hale’s axiom is the very one that Donald Trump’s lawyer, Michael Cohen, summarized to The Daily Beast this week in the apparent belief it was still in effect.

Hale wrote four centuries ago that “The husband cannot be guilty of a rape committed by himself upon his lawful wife, for by their mutual matrimonial consent and contract the wife hath given herself in this kind unto her husband, which she cannot retract.”

As it happens, Hale is also well known for having ordered the hanging of two elderly women charged with witchcraft and “unnatural love.” He thereby established a model for the Salem witchcraft trials in America.

His position regarding marital rape was embraced with more lasting effect by the New World and was still the official view in New York in 1981.

Denise Liberta might have just been turned away when she reported the attack to the police the next day were it not for an exception to the exception that the state legislature had passed in 1978.

Under this new provision, a wife ceased to be rape-able when she was separated from her husband.

Court papers report that Mario Liberta and Denise Liberta were childhood sweethearts who married in 1978 but lived together for less than two years.

“Defendant Mario Liberta began to beat Denise shortly after the birth of their son in October of that year,” the court papers say. “In 1980 Denise received a temporary order of protection from Family Court. The order required defendant to move out and remain away from the family home and Denise. It allowed defendant to visit his son once each weekend.”

The court papers continue: “On the weekend of March 21, 1981 defendant did not visit his son. On Tuesday of the following week he called to request visitation. Denise agreed so long as he picked up the son and her and took them to the motel he was staying at under the understanding that a friend of his would be with them at all times.”

The court papers go on: “The defendant and his friend picked the two up and drove to the hotel. Upon arrival the friend left. Shortly thereafter defendant attacked Denise, threatened to kill her, and forced her to perform fellatio and engage in sexual intercourse with him. He also forced Denise to tell their son to watch.”

The part about the son may have been what made the cops and the prosecutor determined to prosecute Mario Liberta even though no husband in New York history had ever been convicted of raping his wife.

During the four-day trial, Denise Liberta took the stand and recounted her ordeal.

“Denise testified that Mario threatened at least twice to kill her and at least once to kill her son if she did not stop screaming during the rape,” the court papers say. “Mario himself admitted that when Denise entered his motel room he immediately grabbed her by her hair and slapped her several times.”

The jury deliberated for just 25 minutes before returning a guilty verdict.

“It was a miscarriage of justice,” Mario Liberta’s attorney, Bertil Peterson, declared. “I’m surprised at the verdict and I’m doubly surprised that they arrived at it so fast.”

Mario Liberta appealed. The Court of Appeals upheld the conviction by a vote of 6 to 0. It also scrapped the marital exception altogether, making New York the 18th state to shake off Lord Hale’s grandly intoned insanity.

“There is no rational basis for distinguishing between marital rape and non-marital rape,” the court ruled. “Rationales for such a distinction are based either upon archaic notions about consent and property rights or are simply unable to withstand even the slightest scrutiny. An argument based upon supposed consent to such an act is irrational and absurd.”

The court declared: “A married woman has the same right to control her own body as does an unmarried woman. Other traditional justifications that a woman was the property of her husband have long been rejected by this State.”

The court scoffed at the suggestion that “the exemption protects against governmental intrusion into marital privacy and promotes reconciliation of the spouses, and thus, elimination would be disruptive to marriages.”

“The right of privacy protects consensual acts, not violent sexual assaults,” the court said. “A marriage license should not be viewed as a license for a husband to forcibly rape his wife with impunity.”

By then, Mario Liberta had been sentenced to a three- to nine-year term in prison. He served seven years.

In 2007, a second Buffalo man was convicted of marital rape. Anthony Woods had raped and sodomized his wife for four hours.

“How can I rape my wife?” he reportedly asked the arresting officers.

Woods had a previous, non-marital rape conviction. He was sentenced to 50 years for this second offense. He, too, appealed.

“Not unduly harsh or severe,” the appeals court said when it upheld the sentence.

As for Mario Liberta, he was convicted of non-sexual assault in 2008. He is said to have kicked and punched two men and to have attempted to attack one of them with a pair of needle-nosed pliers.

Meanwhile, Donald Trump should count himself lucky that his then-wife, Ivana Trump, was not speaking “in a literal or criminal sense” when she used the word “rape” back in 1989, five years after the court ended a marital exception that never should have been.