Debra Karlstein says her ex’s second wife, Deborah Lee, cheated their three sons of a $1.5 million inheritance.Stefan Jeremiah

A high-powered Manhattan trial lawyer expertly juggled his addiction to cocaine, booze and hookers with a lucrative career — but he was no match for his scheming lover, his ex-wife says.

The woman convinced party-boy Proskauer partner Harry Goldsmith to marry her as he lay dying of pancreatic cancer — then brought a team of lawyers to his deathbed to rewrite his will, spurned spouse Debra Karlstein claims in a Manhattan Surrogate’s Court lawsuit.

Karlstein says the scheme by her ex’s second wife, Deborah Lee, cheated their three young sons of a $1.5 million inheritance.

Adding insult to injury, Lee is suing Karlstein for $155,000 — the balance that Karlstein owed Goldsmith to buy him out of their West 72nd Street apartment, the ex says.

Karlstein says she and her sons — twin 10-year-olds and a 14-year-old — were allowed to live in the $2.3 million apartment as part of her and Goldsmith’s child-support pact. She said she was to then get the home when Goldsmith died in June 2013.

Hank Goldsmith

“Hank had a lot of issues, yes,’’ said Karlstein, who describes her ex in the suit as a “man with many demons,” including, “cocaine, pills and alcohol … sugary foods, nicotine patches, pornography, strip clubs and prostitutes.”

“But he did love his children,’’ she told The Post. “I can’t believe that this is what he would want, to take money out of their pockets.”

In 2010, Karlstein divorced Goldsmith — who once brought a copyright case against Napster, played guitar in a Tom Petty cover band and did a stint in rehab after blowing hundreds of thousands of dollars on cocaine, porn and strip clubs in 2006.

The then-49-year-old Goldsmith began dating the Zimbabwe-born Lee in 2011, about a year before he was diagnosed with terminal cancer in September 2012.

They wed the month after Goldsmith’s diagnosis — just three months before the $775,000-a-year lawyer landed in the emergency room with pneumonia.

Then, “with Hank in medical and psychological distress in the emergency room, his new wife sprang into action to re-do Hank’s estate plan in a manner that secured substantial financial benefits for herself, at the expense of Hank’s and my children,” Karlstein says in court papers.

Karlstein, also a lawyer, said her ex was “under the influences of heavy medication” when Lee contacted Goldsmith’s law partner, who proposed “bringing a crew to the hospital” to sign the legal documents, according to exhibits in the case.

The new will still provides the boys with a $3.75 million life-insurance policy.

In the years before they split, Goldsmith “rarely appeared at the office before early afternoon, and some days not at all,” according to Karlstein’s court papers.

Instead, he frequented a Times Square jiggle joint with another member of Proskauer, who still works at the firm, according to Karlstein’s filing.

A spokeswoman for Proskauer, who represents Lee, said in a statement, “We are saddened by this unwarranted attempt to tarnish Hank’s reputation.”

“Hank Goldsmith was a‎ brilliant trial and appellate lawyer, representing clients with distinction in many important and precedent-setting cases.”

She added, “He loved the practice of law, the firm, his clients and his family, and the feeling was mutual.”