Image copyright Getty Images Image caption President Donald Trump denies the allegations made by Stormy Daniels

US President Donald Trump has mocked porn actress Stormy Daniels in a tweet after a judge dismissed her defamation lawsuit against him.

The judge ruled that a presidential tweet Ms Daniels said was defamatory was protected by the First Amendment, which guarantees freedom of speech.

Mr Trump said he can now "go after Horseface and her 3rd rate lawyer".

The ruling does not affect a separate lawsuit over hush money she says she was paid by Mr Trump's lawyer.

Ms Daniels was also ordered to pay Mr Trump's legal fees, although the amount is yet to be determined. Her lawyer said she would appeal against the decision.

Ms Daniels and her lawyer Michael Avenatti fought back in tweets of their own.

"Ladies and gentlemen, may I present your president," Ms Daniels wrote, saying Mr Trump had shown his "incompetence, hatred of women and lack of self control on Twitter".

Branding him a "disgusting misogynist and an embarrassment to the United States", Mr Avenatti said he and his client would show the world "what a complete shyster and liar you are".

Ms Daniels says she had a sexual affair with Mr Trump in 2006.

She filed the case after the president tweeted that she had invented a story about being threatened for speaking out about the alleged relationship.

Mr Trump has denied any relationship with the actress.

Media playback is unsupported on your device Media caption Could porn star payment bring down Trump?

In an interview with CBS News earlier this year, Ms Daniels said a stranger had approached her while she was with her young daughter, and had threatened her. She later issued an image of the man.

Mr Trump responded to her account on Twitter, saying: "A sketch years later about a nonexistent man. A total con job, playing the Fake News Media for Fools (but they know it)!"

While the judge said this tweet was not defamatory, Ms Daniels' main suit against Mr Trump's former lawyer, Michael Cohen, continues.

In August, Mr Cohen pleaded guilty to violating campaign finance laws during the 2016 presidential election over payments to two women who said they had sexual relationships with Mr Trump. He said he made the payments at Mr Trump's request.