The government said that Michael Cohen was not returned to prison because he’s writing a tell-all book about his time in the Trump administration, but a federal judge disagreed, ordering the lawyer’s release from prison.

Judge Alvin K. Hellerstein said that the government sent Cohen, President Trump’s former attorney, back to prison from home confinement as an act of retaliation because Cohen was writing an unflattering book about his time working for Trump, CNBC reports.

Cohen, who is serving a three-year sentence for fraud and campaign finance violations, will be released from prison by Friday afternoon.

The Trump administration had denied that its decision to return Cohen to prison was because of his planned book, the New York Times reports. The Bureau of Prisons claimed he was sent back to jail because he was “combative” and refused to sign an agreement related to his release.

Cohen said in a court filing that his book, tentatively titled Disloyal: The True Story of Michael Cohen, Former Personal Attorney to President Donald J. Trump, will provide “graphic and unflattering details” about Trump, including “the President’s pointedly anti-Semitic remarks and virulently racist remarks against such Black leaders as President Barack Obama and Nelson Mandela, neither of whom he viewed as real leaders or as worthy of respect by virtue of their race.”

Cohen said he hopes to publish his book before the November presidential election.

Michael Schaub is a Texas-based journalist and regular contributor to NPR.