A federal judge on Thursday dismissed a lawsuit brought against President Trump and his former lawyer by Stormy Daniels, a pornographic film actress who was paid to keep quiet about an alleged affair with Mr. Trump before the 2016 election.

The suit, brought a year ago in California, had sought to release Ms. Daniels from the nondisclosure agreement she had signed. As part of her arrangement, she received $130,000 in hush money through the president’s personal lawyer at the time, Michael D. Cohen.

As he tossed out the case this week, Judge S. James Otero, of United States District Court in Los Angeles, called the legal argument moot, given that Ms. Daniels had not been held to the terms of the agreement.

Indeed, Ms. Daniels and her lawyer, Michael Avenatti, have spoken freely about the arrangement since the filing last March. The lawsuit led to escalating national attention that culminated in Mr. Cohen’s pleading guilty to related campaign-finance crimes last summer.