The tabloid news company American Media Inc. agreed to let a former Playboy model out of a contract that had kept her from talking freely about an alleged affair with Donald J. Trump.

The settlement agreement, reached on Wednesday, ends a lawsuit brought by the model, Karen McDougal, and protects the president from being drawn into a legal case involving efforts to buy the silence of women who had stories to tell about him during the 2016 campaign.

He still faces another lawsuit from Stephanie Clifford, the pornographic film actress known as Stormy Daniels. Ms. Clifford is suing to get out of a deal that Mr. Trump’s personal lawyer, Michael D. Cohen, arranged in 2016 for her silence about an alleged affair. Mr. Trump’s representatives have denied both women’s stories.

In August 2016, A.M.I., which owns The National Enquirer, acquired the rights to Ms. McDougal’s story about Mr. Trump — which it never ran — in return for $150,000 and commitments to use its magazines to promote her current career as a fitness specialist.

Under the terms of Wednesday’s settlement, A.M.I. has the right to up to $75,000 of the profits from any deal she makes in the next year for her story about the alleged affair. According to her lawyer, Peter K. Stris, Ms. McDougal can keep the $150,000 payment, and the publisher will retain the rights to photographs of her that it already has.

In a statement, A.M.I. called the settlement an “amicable resolution” and said that under the new agreement it would devote an upcoming magazine cover and feature article to Ms. McDougal, and would run several of her fitness columns in its publications.

“It’s a total win,” Mr. Stris said in an interview. “We got everything we were fighting for — she got out of the contract, gets the life rights back and owes A.M.I. nothing more.”

In a separate interview, Ms. McDougal expressed elation about the end of her “wild ride,” and said she currently had no plans to sell the rights to her story to a new buyer. “It’s one step at a time for me,” she said. “Today, I’m doing my victory dance.”

Her lawsuit said that A.M.I., whose chairman, David J. Pecker, is a friend of President Trump’s, misled her into signing the contract. It also claimed that Mr. Cohen had inappropriately intervened in the deal. A.M.I. had denied misleading her.

The deal and the extent of Mr. Cohen’s role in it are the subjects of a wide-ranging federal corruption investigation that is, in part, looking into his efforts to protect Mr. Trump’s presidential prospects in 2016.

But that was roughly a week before federal investigators obtained email communications, audio recordings and other documentation from Mr. Cohen during their raid of his office, home and hotel room. Those materials included information about A.M.I. and the McDougal suit, people involved in the case said.

The suit also claimed that Mr. Cohen had been secretly involved in the talks between A.M.I. and Ms. McDougal’s lawyer at the time, Keith M. Davidson — who emailed Mr. Cohen at the end of the negotiations. A spokesman for Mr. Davidson has said the lawyer “fulfilled his obligations and zealously advocated for Ms. McDougal.”

A.M.I. also spoke with Mr. Cohen about Ms. McDougal, though it says it did so only as part of its reporting process.

Mr. Stris said that before reaching the settlement, he was prepared to answer A.M.I.’s motion to dismiss Ms. McDougal’s case with a request for a limited version of pretrial discovery. The move, compelling both sides to share emails and other records, could have provided information that would not be available through the material the F.B.I. seized from Mr. Cohen. An A.M.I. lawyer, Cameron Stracher, said that he doubted the request would have succeeded, and that avoiding discovery was not a motivating factor in the settlement.

The agreement precludes any of that from happening, at least in Ms. McDougal’s civil case against A.M.I., though Mr. Stris said he expected federal investigators to eventually secure everything they needed to fully vet the process behind the deal. “I have tremendous confidence in the men and women of the Southern District of New York,” he said, referring to the federal prosecutors investigating Mr. Cohen.

Mr. Stris said he did not rule out taking legal action if more came to light about potentially inappropriate contact between Mr. Cohen and Mr. Davidson during the course of negotiating her deal. The settlement does not bar Ms. McDougal from claims against either of the men in the future. For now, Ms. McDougal said, “I need to relax and get my life back and de-stress.”

The initial deal prohibited Ms. McDougal from speaking about her alleged affair, but A.M.I. amended the contract after the election to allow her to answer “legitimate press inquiries,” in response to her complaints that the agreement was overly restrictive. In recent months, she has spoken to The New Yorker and Anderson Cooper of CNN.

Separate from the federal investigation into Mr. Cohen, A.M.I. is facing a complaint at the Federal Election Commission that its $150,000 payment to Ms. McDougal was an illegal campaign expenditure. The publisher has denied this and says it acts solely as a news organization with a First Amendment right to run stories — or not run them — as it chooses.

Correction:April 19, 2018

An earlier version of this article misstated a provision in a settlement reached by Karen McDougal and American Media Inc. Under the deal’s terms, A.M.I. has the right to up to $75,000 of the profits from any deal Ms. McDougal makes in the next year for her story about the affair she says she had with Donald J. Trump before he became president. The provision does not apply to any deal made after that.

A version of this article appears in print on , on Page A15 of the New York edition with the headline: Former Playboy Model Is Free to Discuss Alleged Affair. Order Reprints | Today’s Paper | Subscribe