Michael Cohen reached an agreement with federal authorities on Thursday, allowing him to publish his tell-all book about President Donald Trump.

A federal judge in Manhattan ruled that the government retaliated against Cohen when he was sent back to prison after tweeting about publishing a tell-all memoir about Trump, despite being released to home confinement due to coronavirus pandemic. The judge also lifted a provsion that Cohen cannot publish his Trump memoir or communicate with media while serving his sentence at home.

“There shall be no specific media provision governing [Cohen’s] home confinement,” says the agreement filed by federal prosecutors.

The president’s former attorney is serving his three-year sentence due to charges including fraud and lying to Congress in 2018.

After being released from prison to serve his sentence at home amid the pandemic, Cohen was told that he must agree not to speak in public or media, including by publishing a book, during his home confinement. According to court documents, the agreement read: “No engagement of any kind with the media, including print, tv, film, books, or any other form of media/news. Prohibition from all social media platforms.”

“I’ve never seen such a clause in 21 years of being a judge and sentencing people,” U.S. District Court Judge Alvin Hellerstein said. “How can I take any other inference but that it was retaliatory?”

Cohen said in a statement his book “will provide graphic and unflattering details about the President’s behavior behind closed doors.”