(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.

Read More