A woman says she and her divorce lawyer had a tryst in a courthouse stairwell — but what was really over the line was the way he handled her case, new Manhattan court papers show.

Had the lothario lawyer done better legal work, she actually wouldn’t have blown the whistle on the shenanigans, according to the documents obtained by The Post.

“If he had satisfactorily resolved her case, she would not have complained about the texts, photographs and sexual conduct alleged,” the state’s appellate court wrote last week — as it suspended lawyer David Scudieri from practicing law for 1 ½ years over the misconduct raps.

Scudieri, 56, had been hired by the woman, only identified as “Ms. A,’’ in July 2016 and tasked with filing “a child support modification and to compel [the father] to sign documents to obtain passports for the minor children,” according to court papers.

The lawyer and his client then began engaging in a “continued pattern of sexting/texting” before eventually swapping nude photos, the papers say.

The pair continued their relationship for several months — with Scudieri, a named partner at Goldberg, Scudieri & Lindenberg, later insisting that everything was consensual.

They might have kept hooking up, too, if it weren’t for Scudieri doing such a lousy job on the woman’s case, the court papers say.

“[Scudieri’s client] testified that her initial complaint against respondent sent to the [Attorney Grievance Committee] was based upon his inability to obtain a favorable result in her child support matter and his refusal to refund her retainer,” the papers say.

In fact, the woman’s initial complaint last year — which accused Scudieri of losing her case and failing to provide a written retainer agreement — did not mention “any claim of sexual contact because it was ‘more personal,’ however, it did refer to his request for photographs of her,” the court said.

It wasn’t until after Scudieri responded to the complaint and denied the woman’s accusations that she began spilling the beans, the papers show.

“After she received respondent’s answer to her complaint, [the woman] submitted a reply in which she first revealed that respondent ‘took my money, sex chat me, collected tone (sic) of pictures of my body parts, he had oral sex and he did [a] bad job on my case,’” the appellate court said. “She testified that prior to her reply, the only person she told about the stairwell events was her friend.”

Scudieri copped to the racy texts and nude-photo exchange when confronted about them but “vehemently denied liability” for hooking up with his client inside the 111 Centre St. courthouse in 2017.

He admitted that he knew that “having sexual relations with a client … has always been frowned upon in a domestic relations matter” and that engaging in sexual relations could “destroy his career,” according to court docs.

The appellate court, in rendering its decision, noted that Scudieri had said he was undergoing “a litany of family strife’’ at the time, including “an acrimonious divorce’’ and home foreclosure.

“In his 29 years of practice his disciplinary history consisted of only two prior Admonitions he received, one in 1997 for the delayed release of settlement funds and one in 1998 for the neglect of an appeal,’’ the court noted.

“Respondent also offered a character letter attesting to his diligence and honesty as an adversary.”

Messages left on Scudieri’s phone and that of his lawyer were not returned.