President Trump’s former personal lawyer asked a judge this week to bar Michael Avenatti, the attorney representing adult-film actress Stormy Daniels, from communicating with the press and public about a pending lawsuit.

The motion for a restraining order, filed late Thursday in U.S. District Court in California by Michael Cohen, accuses Avenatti of having a “seemingly unquenchable thirst for publicity” and argues that his frequent Twitter postings and TV appearances violate California rules of professional conduct for lawyers.

The publicity is “likely to result in Mr. Cohen being deprived of his right to a fair trial,” the motion reads. It “threatens to turn what should be a solemn Federal Court proceeding into a media circus.”

Avenatti responded quickly — on social media. “The motion for a gag order is a complete joke and baseless,” he tweeted. “Mr. Cohen . . . can’t deal with the truth, the facts, and the law, so they have to resort to unethical, meritless motions.”

Michael Avenatti, the lawyer representing Stormy Daniels against President Trump, has become a national figure. (Allie Caren/The Washington Post)

If Judge S. James Otero agrees to the motion, it would change the nature of a case that has played out on television as much as it has in the courtroom for the past three months.

Avenatti has made regular media appearances — sometimes challenging his opponent to debate him on air — and secured prominent interviews for his client: Daniels’s March appearance on CBS’s “60 Minutes” attracted more than 20 million viewers, the show’s highest ratings in almost a decade.

Daniels, whose real name is Stephanie Clifford, filed a lawsuit in early March against Cohen, Trump and a shell company Cohen set up, seeking to free herself from a hush agreement she signed to prevent her speaking about an alleged affair with Trump. She claims the confidentiality agreement is invalid because Trump did not sign it. Cohen paid her $130,000 in the closing days of the 2016 election. Trump subsequently acknowledged that he reimbursed Cohen for that payment.

Brent H. Blakely, who filed the motion on Cohen’s behalf, alleges that since Daniels filed suit, Avenatti has made more than 120 media appearances and issued at least 439 tweets relating to the lawsuit or to Cohen. The motion claims that Avenatti has “repeatedly denigrated Mr. Cohen, predicted that Mr. Cohen would be indicted for bank fraud, wire fraud, campaign finance violations, and accused Mr. Cohen of hiring a ‘thug’ to allegedly threaten Ms. Clifford.”

This is not the first time Avenatti has been accused of overusing the media. In May, he withdrew a petition to participate in a separate proceeding involving Trump and Cohen after U.S. District Judge Kimba Wood told him that his “publicity tour” was incompatible with giving Cohen a fair trial in her court.

Avenatti has continued to appear on news programs and late-night shows. On Wednesday, the lawyer appeared with Trump’s short-lived communications director Anthony Scaramucci on “The Late Show With Stephen Colbert,” where he was outspoken in his criticism of Cohen.

Otero declined to grant Cohen emergency relief, setting a briefing schedule Friday that begins in late June.