The decision comes just under two weeks after Cohen was re-admitted to a medium-security federal correctional facility in Otisville, New York, and two months after his initial home confinement release due to concerns about COVID-19.

U.S. District Judge Alvin Hellerstein ordered Cohen’s release, set for Friday at 2 p.m. Hellerstein argued the decision to take Cohen back into custody earlier this month was “retaliatory” during Thursday’s hearing, since it closely followed the former Trump lawyer resisting requirements that he refrain from writing a critical tell-all book about the president while at home on release.

Cohen was taken into custody in May of last year after he was found guilty of tax and bank fraud, as well as campaign finance violations in connection to hush payments sent to Stormy Daniels and Karen McDougal. Both women said they were engaged in affairs with Trump in the early 2000s. Trump denied their claims.

Hellerstein’s retaliation argument during Thursday’s hearing supported a similar one outlined in a habeas corpus petition filed by Cohen’s lawyers and the American Civil Liberties Union (ACLU) on Monday. The petition sought Cohen’s immediate release from custody and claimed conditions of his original furlough violated the First Amendment.

“He is being held in retaliation for his protected speech, including drafting a book manuscript that is critical of the President—and recently making public his intention to publish that book soon, shortly before the upcoming election,” it stated, noting later that Cohen’s book “provides graphic details about the President’s behavior behind closed doors” and information about its contents were previously made public.

The petition went on to suggest conditions of Cohen’s original home release, meant to last through the remainder of his three-year sentence, were unconstitutional. Probation officers employed by the Federal Bureau of Prisons (BOP) presented the conditions to Cohen on July 9, one day before ordering his return to custody. Cohen’s legal representatives claimed this was directed by prosecutors.

“As a condition of his release—a release BOP already had determined was necessary to protect Mr. Cohen’s health—he had to agree to a complete bar on speaking to or through any media of any sort, including via a book,” it continued. According to the petition, Cohen shared an update about the tell-all to Twitter one week before the BOP officers presented his conditions. In the update, Cohen said his book was nearly finished.

The terms of Cohen’s home confinement will now be renegotiated.

Newsweek reached out to Hellerstein and the Federal Bureau of Prisons for comments but did not receive replies in time for publication.