A federal judge in California on Monday dismissed a defamation suit brought by porn star Stormy Daniels and her attorney Michael Avenatti against President Donald Trump, court filings show.

Judge S. James Otero said that Trump's April tweet, accusing Daniels of a "total con job" after her appearance on daytime talk show "The View," was "the definition of protected rhetorical hyperbole." Otero further ruled that the president was entitled to attorney's fees from Daniels.

Trump's lawyer in the dispute, Charles Harder — who also represents Trump in an arbitration fight against former White House official Omarosa Manigault-Newman — took a victory lap in a statement sent to CNBC.

"No amount of spin or commentary by Stormy Daniels or her lawyer, Mr. Avenatti, can truthfully characterize today's ruling in any way other than total victory for President Trump and total defeat for Stormy Daniels," Harder said in the statement. "The amount of the award for President Trump's attorneys' fees will be determined at a later date."

Avenatti, in a statement to CNBC, said Harder's statement was "complete nonsense."

"Ms. Daniels' other claims against Trump and Cohen proceed unaffected. Trump must have written this release because it is as deceptive as his claims about the inauguration attendance," Avenatti added.

In a tweet shortly after the ruling was made public, Avenatti said he had filed an appeal in the ninth circuit court.

Michael Avenatti tweet: Here is the Notice of Appeal we just filed with the Ninth Circuit relating to the defamation claim against Trump. His record before the Ninth Circuit has been anything but good. #Basta

Daniels, whose real name is Stephanie Clifford, is suing Trump and his former personal lawyer Michael Cohen in a separate suit to void a $130,000 nondisclosure agreement she signed a few weeks before the 2016 presidential election. The hush-money deal muzzled her from discussing an alleged affair with Trump from years earlier.

Trump has denied having sex with Daniels.

In a "60 Minutes" interview in March, Daniels said that she and her daughter had been threatened in 2011 by an unknown man in a parking lot in Las Vegas who told her to "leave Trump alone." The alleged incident occurred during a time when she was in talks with a magazine about going public with her story of the tryst with Trump at a Lake Tahoe celebrity golf tournament in 2006.

When she went on "The View" the next month, Daniels revealed a composite of the man's face drawn by a sketch artist based on her memory of the incident.

Trump, after the program ended, tweeted that she was "playing the Fake News Media for Fools (but they know it)!"

Trump tweet

On April 30, she filed the defamation suit, arguing that Trump had posted a false statement against her that was defamatory because it suggested she was falsely accusing a man of committing a crime.

Otero disagreed. "Mr. Trump's tweet displays an incredulous tone, suggesting that the content of his tweet was not meant to be understood as a literal statement" about Daniels.

The judge adds in the court document: "If this Court were to prevent Mr. Trump from engaging in this type of 'rhetorical hyperbole' against a political adversary, it would significantly hamper the office of the President."



-- CNBC's Brian Schwartz contributed to this report.

WATCH: Here are some of President Trump's confusing claims so far this year