LOS ANGELES — Lawyers for President Donald Trump asked a court Monday for nearly $800,000 in lawyers’ fees and penalties from porn actress Stormy Daniels for a failed defamation lawsuit against him.

Attorney Charles Harder defended ringing up a nearly $390,000 legal bill for the president and asked for an equal amount in sanctions as a deterrent against a “repeat filer of frivolous defamation cases.”

Judge S. James Otero didn’t immediately rule. He noted that fees by Harder’s firm — as high as $840 an hour — were reasonable but the 580 hours spent on the case appeared to be excessive and might be trimmed in his eventual award. He didn’t indicate how he felt about the requested penalties, but had questioned whether attorneys’ fees alone would serve as a deterrent.

Harder had not put a dollar figure on sanctions he was seeking before the hearing and Daniels’ attorney Michael Avenatti objected vehemently, calling it “absurd and outrageous.”

“You can’t just pick a number out of thin air in an effort to put my client under Donald Trump’s thumb and intimidate her,” Avenatti said.

Daniels, whose real name is Stephanie Clifford, alleges she had a one-night affair with Trump in 2006. She sued him earlier this year seeking to break a non-disclosure agreement she signed days before the 2016 election about the tryst as part of a $130,000 hush money settlement. Trump has denied the affair, but essentially acknowledged the payment to Daniels.

Despite the deal to stay quiet, Daniels spoke out publicly and alleged that five years after the affair she was threatened to keep quiet by a man she did not recognize in a Las Vegas parking lot. She also released a composite sketch of the mystery man.

She sued Trump for defamation after he responded to the allegation by tweeting: “A sketch years later about a nonexistent man. A total con job, playing the Fake News Media for Fools (but they know it)!”

Otero ruled in October that Trump’s statement was “rhetorical hyperbole” against a political adversary and was protected speech under the First Amendment.

Although the lawsuit didn’t get far before Otero tossed it, he said it was a “one of a kind” case that demanded a fair bit of legal work.

“Given a case of this magnitude, you have to err on the side of being thorough,” Otero said.

Daniels has appealed Otero’s decision and Avenatti said Monday he expects to prevail at a higher court.

Avenatti, who has positioned himself as a Trump foe and is considering a run for president in 2020, also said he will be seeking attorney’s fees against Trump in the ongoing hush money case and he anticipates being awarded a figure that “dwarfs exponentially” what Trump is seeking in the defamation case, possibly exceeding $2 million.

Trump’s lead attorney said the fees and unspecified monetary sanctions were earned because of the extraordinary nature of the defamation case and because of Avenatti’s gamesmanship.

“This action is virtually unprecedented in American legal history,” Harder wrote in court papers. Daniels “not only brought a meritless claim for defamation against the sitting president of the United States, but she also has engaged, along with her attorney, in massive national publicity.”

In a related case in which Daniels has alleged that her former lawyer, Keith Davidson, colluded with Trump’s former personal lawyer Michael Cohen to have her publicly deny the affair with Trump, Avenatti and Cohen’s lawyer briefly traded accusations Monday in the hallway of a Santa Monica courthouse.

Standing nose-to-nose with attorney Brent Blakely, Avenatti told him he represented a felon. Blakely shot back that Avenatti is a felon. Avenatti said he’s never been convicted of a crime.

Cohen has pleaded guilty to several felonies and admitted funneling money to Daniels to keep her quiet about an affair she has said she had with Trump.

Avenatti was arrested last month on suspicion of domestic violence.

Prosecutors declined bringing felony charges against Avenatti. They are investigating whether he should face a misdemeanor charge for allegations he roughed up a girlfriend. Avenatti has denied wrongdoing.

The Cohen and Davidson lawsuit in Los Angeles County Superior Court has been put on hold, though a hearing is scheduled May 22.