NEW YORK — The book manuscript being drafted by President Trump's former personal lawyer Michael Cohen alleges that Trump has made racist comments about his predecessor Barack Obama and the late South African leader Nelson Mandela, according to court filings made public Monday night that contend Cohen was sent back to prison this month as retaliation for seeking to publish his memoir before November's election.

The lawsuit seeks Cohen’s immediate release from federal custody. He was rearrested July 9, less than two months after he was approved to serve the remainder of his sentence on home confinement because of the coronavirus pandemic. His attorneys allege that Cohen’s First Amendment rights were violated when he was detained at the federal courthouse in Manhattan during a meeting with probation officers, who had asked him to sign a gag order prohibiting him from speaking to the media or publishing a book while serving the rest of his sentence.

Cohen’s suit names Attorney General William P. Barr and Federal Bureau of Prisons officials, in their official capacities. The case was assigned to U.S. District Judge Alvin Hellerstein in the Southern District of New York, and an initial hearing was scheduled for Thursday.

Neither the Justice Department nor the White House responded to requests for comment.

In the court filings, Cohen said his book will contain “my firsthand experiences and observations based on my decade-long employment and relationship with Mr. Trump and his family, both before and after he was elected.” Its working title is “Disloyal: The True Story of Michael Cohen, Former Personal Attorney to President Donald J. Trump,” the documents say.

“In particular, my book will provide graphic and unflattering details about the President’s behavior behind closed doors,” Cohen wrote as part of the court filings. The memoir “describes 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 wrote.

The documents offer no further details about the manuscript’s content.

Authorities have said Cohen was taken back into custody because he refused to wear an ankle monitor, a claim his legal team disputes. Cohen’s lawyers also contend he did not refuse to acknowledge the media policy presented to him before his arrest, but rather that he expressed concerns about it and asked for an amendment.

Cohen’s legal team, including lawyers from the American Civil Liberties Union and former federal prosecutor Danya Perry, allege that his home confinement was revoked because of his book plans. 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,” the filing says.

Cohen, 53, said in the filing that he had been writing daily, in the open, from the prison law library before his release in May.

The order he was asked to sign required “no engagement of any kind with the media, including print, TV, film, books, or any other form of media/news.” It also prohibited “all social media platforms” and barred family or friends from posting on his behalf.

The provision was crafted specifically for Cohen and was not part of any standard procedure, his lawyers argue.

Cohen’s lawsuit references recent efforts to block the publication of books by Trump’s former national security adviser John Bolton and the president’s niece Mary L. Trump. Both accounts are intensely critical of Trump and disclose biting allegations of improper behavior. Cohen’s lawyers allege the effort to silence him is part of a pattern.

In Bolton’s case, the Justice Department had sued on behalf of the administration, claiming “The Room Where it Happened” contained privileged material. A judge sided with Bolton and the book was released in late June.

Mary Trump was sued by the president’s brother, Robert Trump, who insisted she was bound by a confidentiality clause in an estate settlement agreement signed decades ago. A judge sided with her and the book was released last week.

Cohen recently received a cease-and-desist letter from Charles Harder, the attorney who challenged Mary Trump. Harder said Cohen was bound by a nondisclosure agreement, which Cohen disputes. One of Cohen’s lawyers asked for a copy of the agreement but it was never sent, the lawsuit says.

Harder could not immediately be reached for comment.

Cohen has been held in solitary confinement at a federal prison in Otisville, N.Y., since he was taken back into custody earlier this month, the court documents say.

Cohen was convicted of tax evasion, making false statements, campaign finance violations and lying to Congress in 2018. He admitted to making hush-money payments during the 2016 presidential campaign to two women who alleged having affairs with Trump several years ago. The president has denied their claims.