Ms Daniels had argued she had been defamed but on Monday judge S James Otero disagreed, dismissing her lawsuit and ordering her to pay Mr Trump's legal costs.
Daniels filed the lawsuit against Trump in April, condemning a tweet he posted about her interview on CBS' "60 Minutes", in which she described a man who she claimed threatened her and her daughter, telling them not to speak about Daniels' alleged affair with Trump.
The defamation claim is separate from another lawsuit that Daniels filed against Trump, which is continuing.
Stormy Daniels was also ordered to pay Mr Trump's legal fees, although the amount is yet to be determined.
"The Court agrees with Mr Trump's argument because the tweet in question constitutes "rhetorical hyperbole" normally associated with politics and public discourse in the United States", Otero wrote in his ruling.
Michael Avenatti, Clifford's attorney and a potential 2020 Democratic presidential candidate, said Clifford would appeal.
"Having granted the Special Motion [to dismiss] and denied Plaintiff leave to amend, the Court finally holds that Defendant is entitled to attorney's fees", Otero said.
The unidentified man allegedly warned her not to publicize her purported sexual affair with Trump.
Trump and his team countered Ms Daniels' accusations by claiming her story was a fabrication.
"No amount of spin or commentary by Stormy Daniels or her lawyer, Mr Avenatti, can truthfully characterise today's ruling in any way other than total victory for President Trump and total defeat for Stormy Daniels", Mr Harder said in a statement.
Avenatti called the ruling "limited" on Twitter and said it did not affect Daniels's primary case against Trump and his former attorney Michael Cohen, which seeks to invalidate her 2016 nondisclosure agreement.
"The First Amendment (of the US Constitution) protects this type of rhetorical statement".
In the April 2018 tweet, Trump said "A sketch years later about a nonexistent man. Harder's release because it is as deceptive as his claims about the inauguration attendance", he told Law&Crime in a statement. "We will appeal the dismissal of the defamation cause of action and are confident in a reversal", he tweeted.
Cohen pleaded guilty in August to campaign finance violations alleging he coordinated with Trump on a hush-money scheme to buy the silence of Daniels and a Playboy model who alleged affairs.
Daniels has said she had sex once with Trump in 2006, and carried on a friendship with him for about a year.