WASHINGTON — David Pecker, the CEO of American Media Inc., which is the publisher of the National Enquirer, has been granted immunity and is cooperating with federal prosecutors as part of the investigation of Michael Cohen and payments made to two women who claim to have had affairs with Donald Trump.

Vanity Fair reported on the immunity agreement, and it was confirmed by the New York Times and NBC News.

The court documents unsealed at the time of Cohen’s guilty plea earlier this week outline a pattern of cooperation between AMI and the Trump campaign starting in 2015. Prosecutors claim that AMI and the Enquirer tipped off the Trump campaign of potentially damaging stories. In the case of Karen McDougal, who claims she had an affair with Trump in 2006 and 2007, AMI’s Dylan Howard arranged a $150,000 payment for her limited life rights. The purpose was to keep the story from getting published elsewhere, while it never saw the light of day in the Enquirer.

Pecker is a friend of Trump’s and would have access to emails and other records to corroborate prosecutors’ claims about the payments and whether Trump was aware of them.

Cohen plead guilty to five counts of tax fraud, one count of lying on a bank application, and two campaign finance violations. He told a judge that he arranged the payments at Trump’s direction, with the goal of preventing potentially embarrassing information from influencing the election.

A spokesman for the U.S. Attorney’s Office in New York declined to comment. A spokesman for AMI did not return a request for comment.

During the campaign, the Enquirer ran almost universally favorable coverage of Trump and negative stories about his rivals, including Ted Cruz and Hillary Clinton.

A question raised by campaign finance experts is whether AMI would also have liability. Federal law prohibits corporations from directly contributing to campaigns.

Trevor Potter, the founder and president of the Campaign Legal Center and former chairman of the Federal Election Commission, said earlier this week that “generally, the corporate parent of a news organization is not protected by the ‘press exemption,’ especially when acting outside their ‘press function.’

“Here, Cohen says they entered into an agreement with Trump and his campaign to use corporate money to squelch information detrimental to Trump’s election. That presents a serious legal problem for AMI.”