CNN  — 

A lawsuit by adult film star Stormy Daniels against President Donald Trump over a non-disparagement agreement has been tossed out of federal court.

US District Judge James Otero says the suit, which sought to invalidate the $130,000 agreement that kept Daniels from speaking publicly about her allegations of an affair with Trump ahead of the 2016 election, should be sent back to California Superior Court. In his ruling, Otero says the suit “lacks subject matter jurisdiction.”

By remanding the case back to where it was first filed, Otero made it clear the case is over.

Daniels, whose real name is Stephanie Clifford, says she and Trump had an affair in 2006, after he married first lady Melania Trump and she gave birth to their son, Barron. Trump has denied having an affair with Daniels.

Trump’s former personal lawyer, Michael Cohen, arranged the nondisclosure agreement and paid Daniels $130,000. He admitted in federal court that “in coordination and at the direction of a candidate for federal office,” he kept information that would have harmed Trump from becoming public during the 2016 election cycle. He has since said that the candidate was Trump.

Cohen has since been sentenced to three years in prison after pleading guilty to nine charges, including campaign-finance violations related to payments he arranged to silence women who claimed affairs with Trump – including Daniels. Trump has denied having affairs with the women.

During the course of the case, Cohen and Trump agreed with Daniels saying the agreement would not be enforced. But, Daniels’ attorney Michael Avenatti said his client wanted the judge to rule that what Cohen and Trump did was illegal.

Instead, Daniels’ case was dismissed in favor of the defendants.

By dismissing the case, the judge essentially gave Daniels what she wanted all along – to be able to tell her story without the fear of being sued for millions of dollars, Avenatti said.

“The court found that Ms. Daniels received everything she asked for by way of the lawsuit – she won,” Avenatti told CNN.

Otero is the same judge who also dismissed Daniels’ separate defamation cases against Trump and Cohen. In addition to dismissing the defamation lawsuit, Otero ordered Daniels to pay nearly $300,000 in attorney’s fees.

Daniels sued the President after he said in a tweet posted in April that her tale of a man threatening her not to come forward with her story of her alleged affair with Trump was “a total con job.” Trump had asked Otero to dismiss the lawsuit.

Daniels told CBS’ “60 Minutes” in March 2018 that she was approached in a Las Vegas parking lot while she was with her daughter in 2011. She said a man walked up to her and said, “Leave Trump alone. Forget the story,” and looked at her infant daughter and said, “That’s a beautiful little girl. It’d be a shame if something happened to her mom.”

At the time, Daniels had agreed to tell her story to In Touch magazine for $15,000, but two sources told “60 Minutes” that the deal fell through because Cohen threatened to sue the publication. Daniels said she never got paid.

Trump’s attorney, Charles Harder, told CNN in a statement, “The US District Court confirmed today that the claim against the President has no basis in law. Combined with the attorneys’ fees and sanctions award in the President’s favor totaling $293,000, the President has achieved total victory.”

“Clifford’s attorney would claim victory if he got run over by a bus,” added Brent Blakely, Cohen’s attorney. “Clifford has lost every argument in these lawsuits since day one – her defamation cases have been dismissed and now the Court has granted EC’s motion regarding subject matter jurisdiction.”