Ex-Playboy model Karen McDougal has been released from a $150,000 contract with tabloid publisher American Media, or AMI, that barred her from discussing an alleged affair with President Donald Trump.

"I am pleased to have reached a settlement with AMI on my own terms, which restores to me the rights to my life story and frees me from this contract that I was misled into signing nearly two years ago," McDougal said in a statement Wednesday.

"My goal from the beginning was to restore my rights and not to achieve any financial gain, and this settlement does exactly that."

McDougal sued AMI, which publishes the National Enquirer, to void the deal she signed in August 2016, a few months before the presidential election.

McDougal sold AMI the rights to her story about the alleged tryst, but in a practice reportedly known as "catch and kill," the publisher never ran the story.

AMI's CEO, David Pecker, has long maintained a friendly relationship with Trump.

McDougal said AMI misled her about the terms of the contract. Her suit alleged that the stipulations of the deal also included guarantees that she would appear on the cover of two of AMI's fitness magazines and write more than 120 articles for the publisher.

But the wording in the agreement allowed AMI to shirk the provisions that McDougal thought were obligatory. The publisher agreed to the settlement on Wednesday.

Trump has denied the affair ever occurred.

The agreement saves Trump from being further ensnared in a drawn-out legal fight ahead of the 2018 midterm elections. But Trump has only become more deeply entrenched in a separate lawsuit with a woman seeking to sever her nondisclosure pact over an alleged affair with him.

In the latter case, porn star Stormy Daniels is suing Trump and his longtime lawyer, Michael Cohen, to void a deal for her silence about an alleged affair — brokered just a few weeks before the November 2016 election.

Daniels, whose real name is Stephanie Clifford, was paid $130,000 as part of the deal, which kept her from talking about an alleged affair with Trump. Daniels has offered to return the payment in exchange for her freedom to speak about the alleged affair.

The White House has denied the affair on Trump's behalf, though Trump publicly acknowledged the lawsuit for the first time earlier this month by denying any knowledge of Daniels' payment at the time it was made.

Daniels and her lawyer, Michael Avenatti, attended a Manhattan court hearing on Monday for Cohen, whose property was raided last week by FBI agents. Investigators seized materials related to Daniels and McDougal, as well as the infamous "Access Hollywood" tape in which Trump boasts about sexual harassment.

McDougal alleged in a court filing that Cohen was connected to her case as well. She said she was unaware that her lawyer at the time, Keith Davidson, was in contact with Cohen.

— CNBC's Dan Mangan contributed to this report.