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.
“Federal Judge throws out Stormy Danials lawsuit versus Trump. Trump is entitled to full legal fees.” @FoxNews Great, now I can go after Horseface and her 3rd rate lawyer in the Great State of Texas. She will confirm the letter she signed! She knows nothing about me, a total con!— Donald J. Trump (@realDonaldTrump) October 16, 2018
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".
Ladies and Gentlemen, may I present your president. In addition to his...umm...shortcomings, he has demonstrated his incompetence, hatred of women and lack of self control on Twitter AGAIN! And perhaps a penchant for bestiality. Game on, Tiny. https://t.co/6DpDD5ELtj— Stormy Daniels (@StormyDaniels) October 16, 2018
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".
You are a disgusting misogynist and an embarrassment to the United States. Bring everything you have, because we are going to demonstrate to the world what a complete shyster and liar you are. How many other women did you cheat on your wife with while you had a baby at home? https://t.co/npOKOEFju6— Michael Avenatti (@MichaelAvenatti) October 16, 2018
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.
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.