NEW YORK (AP) — Michael Avenatti was sentenced Thursday to four years in prison for cheating client Stormy Daniels, the porn actor who catapulted him to fame, of hundreds of thousands of dollars in book proceeds.

The California lawyer, currently incarcerated, learned his fate in Manhattan federal court, where Judge Jesse M. Furman said the sentence will mean that Avenatti will spend another 2 1/2 years in prison on top of the 2 1/2 years he is already serving after another fraud conviction.

The judge said Avenatti’s crime against Daniels was made “out of desperation” when his law firm was struggling. He called Avenatti’s behavior “craven and egregious” and blamed it on “blind ambition.”

Prior to sentencing being announced, Avenatti, wearing his prison uniform, choked up several times as he delivered a lengthy statement, saying he had “disappointed scores of people and failed in a cataclysmic way.”

At trial earlier this year, Avenatti represented himself, cross-examining his former client for hours about their experiences in early 2018, when she signed a book deal that provided an $800,000 payout. Prosecutors said he illegally pocketed about $300,000 of her advance on “Full Disclosure,” published in fall 2018.

The book’s publication came at a time when Avenatti’s law practice was failing financially even as he appeared regularly on cable television news channels. In the appearances, he attacked then-President Donald Trump as he represented Daniels in lawsuits meant to free her from a $130,000 hush payment she received shortly before the 2016 presidential election to remain silent about a tryst she said she had with Trump a decade earlier. Trump denied it.

Daniels was not in court. A lawyer spoke on her behalf, saying it was “truly shocking” that Avenatti tried to portray himself as a champion of his clients during his statement.

His conviction for aggravated identity theft required a mandatory two-year prison sentence. He’s already serving a 2 1/2-year sentence for trying to extort Nike. Avenatti was convicted of threatening to ruin the shoemaker’s reputation if it did not pay him up to $25 million.

And he faces a retrial in California on charges that he cheated clients and others of millions of dollars there.

In a presentence submission, Avenatti’s lawyers cited an apology letter Avenatti recently wrote to Daniels in which he said: “I am truly sorry.”

But prosecutors in a sentencing submission last week urged that that he should face “substantial” additional time in prison for a wire fraud conviction and criticized his apology letter, saying the 51-year-old failed to apologize for his actual crime.

And they recalled that during “an extremely lengthy” cross-examination, he “berated his victim for lewd language and being a difficult client, questioned her invasively about marital and familial difficulties, and sought to cast her as crazy, much as he did during the course of his fraud to prevent her own agent and publisher from responding to her pleas for help.”

“The defendant certainly had every right to defend himself at trial. But he is not entitled to a benefit for showing remorse, having done so only when convenient and only after seeking to humiliate his victim at a public trial, and denigrating and insulting her for months to her agent and publisher while holding himself out as taking up her cause against the powerful who might have taken advantage of her,” prosecutors wrote.