A defamation lawsuit filed by adult film actor Stormy Daniels against Donald Trump has been dismissed by a federal court, with the judge saying the tweet at the heart of the case was protected by free speech laws.

Daniels, whose real name is Stephanie Clifford, has said she had a sexual encounter with Trump in 2006. Daniels has said that in 2011, a man approached her in a Las Vegas parking lot and threatened her after she had agreed to talk about her experience with Trump in an interview. She then released a sketch of the man.

In the lawsuit, Daniels alleged that a Trump tweet, which said she had fabricated the encounter, had defamed her, saying it made her out to be a liar.

In the April 2018 tweet, Trump said “A sketch years later about a nonexistent man. A total con job, playing the Fake News Media for Fools (but they know it)!”

In Monday’s decision from S James Otero, a federal judge in the central district of California, it was found that “Mr Trump’s statement constituted ‘rhetorical hyperbole’ that is protected by the first amendment.”

He noted “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. Any strongly-worded response by a president to another politician or public figure could constitute an action for defamation.” Otero also went on to order Daniels to pay Trump’s legal fees, but has not yet fixed an amount.

Michael Avenatti, Daniel’s attorney and a potential 2020 Democratic presidential candidate, said Clifford would appeal. On Twitter, he said “Daniels’ other claims against Trump and [former Trump attorney Michael] Cohen proceed unaffected. Trump’s contrary claims are as deceptive as his claims about the inauguration attendance.” Avenatti added “we will appeal the dismissal of the defamation cause of action and are confident in a reversal.”

Daniels has also sued over a $130,000 hush money agreement over the alleged encounter with Trump.

In a statement, Charles Harder, Trump’s personal attorney said “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.”

Avenatti countered early on Tuesday, with a tweet about the various court cases involving Daniels and the president, and declaring that the above statement “is an outright lie”.

“The American public deserves much better from Mr Trump,” he said.