As a presidential candidate in August 2015, Donald Trump huddled with a longtime friend, media executive David Pecker, in his cluttered 26th floor Trump Tower office and made a request.

What can you do to help my campaign? he asked, according to people familiar with the meeting.

Mr. Pecker, chief executive of American Media Inc., offered to use his National Enquirer tabloid to buy the silence of women if they tried to publicize alleged sexual encounters with Mr. Trump.

Less than a year later, Mr. Trump asked Mr. Pecker to quash the story of a former Playboy model who said they’d had an affair. Mr. Pecker’s company soon paid $150,000 to the model, Karen McDougal, to keep her from speaking publicly about it. Mr. Trump later thanked Mr. Pecker for the assistance.

The Trump Tower meeting and its aftermath are among several previously unreported instances in which Mr. Trump intervened directly to suppress stories about his alleged sexual encounters with women, according to interviews with three dozen people who have direct knowledge of the events or who have been briefed on them, as well as court papers, corporate records and other documents.

While President Trump publicly fought with women leading up to the 2016 election, in private he directed schemes to silence their stories of two alleged affairs. Here’s a timeline of Trump’s personal involvement.

Taken together, the accounts refute a two-year pattern of denials by Mr. Trump, his legal team and his advisers that he was involved in payoffs to Ms. McDougal and a former adult-film star. They also raise the possibility that the president of the United States violated federal campaign-finance laws.

The Wall Street Journal found that Mr. Trump was involved in or briefed on nearly every step of the agreements. He directed deals in phone calls and meetings with his self-described fixer, Michael Cohen , and others. The U.S. attorney’s office in Manhattan has gathered evidence of Mr. Trump’s participation in the transactions.

On Thursday, the White House referred questions about Mr. Trump’s involvement in the hush deals to the president’s outside counsel Jay Sekulow , who declined to comment.

In an Oct. 23 interview with the Journal, Mr. Trump declined to address whether he had ever discussed the payments with Mr. Cohen during the campaign.

“Nobody cares about that,” he said. He described Mr. Cohen as a “public-relations person” who “represented me on very small things.”

Mr. Cohen, who left the Trump Organization to serve as the president’s personal attorney in early 2017, and other aides denied Mr. Trump played any role in the two hush-money deals when they were first reported in the Journal.

Federal prosecutors in Manhattan came to believe otherwise. In August, they outlined Mr. Trump’s role—without specifically naming him—in a roughly 80-page draft federal indictment they had been preparing to file against Mr. Cohen.

When Mr. Cohen pleaded guilty that month to campaign-finance violations, prosecutors filed a 22-page charging document asserting that Mr. Cohen “coordinated with one or more members of the campaign, including through meetings and phone calls, about the fact, nature, and timing of the payments.”

The unnamed campaign member or members referred to Mr. Trump, according to people familiar with the document.

The revelations about Mr. Trump’s involvement in the hush-money deals come as special counsel Robert Mueller continues his probe into Russian electoral interference, and as a newly elected Democratic majority in the House of Representatives has signaled its intention to investigate the Trump administration when it takes power. Manhattan federal prosecutors who investigated Mr. Cohen are now examining business dealings by the Trump Organization.

Mr. Cohen, who implicated the president in his crimes when he pleaded guilty in August, has met with investigators for Mr. Mueller and with federal prosecutors in New York, seeking to provide information that could mitigate his punishment. His sentencing hearing is set for Dec. 12.

He told federal prosecutors he conferred with Mr. Trump in the weeks before the 2016 election about paying Stephanie Clifford , the former adult-film star known professionally as Stormy Daniels, to keep quiet about her allegations of a sexual encounter with Mr. Trump. He told them that Mr. Trump urged him to “get it done.”

Mr. Cohen has also described to prosecutors his discussions with Mr. Trump and a Trump Organization executive about how to pay Ms. Clifford without leaving the candidate’s fingerprints on the deal.

Mr. Trump’s involvement in the payments, by itself, wouldn’t mean he is guilty of federal crimes, according to Richard Hasen , a law professor at University of California, Irvine, who specializes in election law. A criminal conviction would require proof Mr. Trump willfully skirted legal prohibitions on contributions from companies or from individuals in excess of $2,700, he said.

When the Justice Department accused John Edwards, a former senator from North Carolina, of using illegal campaign contributions to conceal an affair during his 2008 presidential run, he argued the money was meant to hide his mistress from his wife, not to influence the election. A jury acquitted him of one charge and deadlocked on the rest.

Managing bad press

Mr. Trump was leading in most polls for the Republican presidential nomination in the summer of 2015 after announcing his candidacy for president. His past behavior with women—flings with models and divorces that played out in the New York tabloids—caused concern among his advisers.

Mr. Pecker could help manage bad press. The men’s relationship dated to the 1990s, when Mr. Pecker’s former employer, Hachette Filipacchi Magazines, put out “Trump Style,” a quarterly magazine for guests at Trump properties.

When Mr. Pecker took over as chief executive of American Media in the late 1990s, he imposed a moratorium on negative stories about Mr. Trump, who was known among Enquirer staff as an “F.O.P.,” or Friend of Pecker.

Mr. Pecker’s August 2015 Trump Tower meeting was arranged by Mr. Cohen. The media executive promised Mr. Trump he would flag to Mr. Cohen any negative stories about women that came to the Enquirer’s attention.

In May 2016, Ms. McDougal, the 1998 Playmate of the year, began to consider telling her story of a nearly yearlong affair with Mr. Trump. She believed the story would come out regardless, after another former Playboy model posted a tweet alluding to a relationship between the two.

Ms. McDougal retained Keith Davidson , a Los Angeles lawyer specializing in representing women who’d had affairs with celebrities. Mr. Davidson reached out to Dylan Howard , American Media’s New York-based chief content officer, to gauge the company’s interest in buying Ms. McDougal’s story.

Messrs. Pecker and Howard alerted Mr. Cohen, who in turn warned Mr. Trump, by then the presumptive Republican presidential nominee, who in turn phoned Mr. Pecker for help.

On June 20, 2016, Mr. Howard flew to Los Angeles to meet Ms. McDougal at her lawyer’s office.

Mr. Howard spent hours interviewing Ms. McDougal, pressing her for every detail of the alleged affair. Ms. McDougal seemed reluctant to go public with her story.

“I don’t want to be the next Monica Lewinsky,” Ms. McDougal said, referring to the young White House intern who was vilified after her affair with President Bill Clinton became public. Mr. Howard told her that without documents corroborating her story, it wouldn’t be worth more than $15,000.

When Mr. Howard finished interviewing Ms. McDougal that day, he and Mr. Pecker got on a three-way call with Mr. Cohen to discuss what she had said. They noted she had produced no proof of an affair with Mr. Trump.

Brendan McDermid/REUTERS Michael Cohen on whether he is loyal to Donald Trump 2017 ’18 “I’m the guy who would take a bullet for the president.” “My wife, my daughter and my son have my first loyalty and always will.” Mark Wilson/Getty Images Donald Trump on whether he knew about the payment to Stormy Daniels 2017 ’18 Did you know about the $130,000 payment to Stormy Daniels? “No.” Do you know where he got the money to make that payment? “No, I don’t know.” “Mr. Cohen, an attorney, received a monthly retainer, not from the campaign and having nothing to do with the campaign, from which he entered into, through reimbursement, a private contract between two parties.” Mary Altaffer/AP Photo Michael Cohen on why he paid Stormy Daniels, whose given name is Stephanie Clifford 2017 ’18 “The payment to Ms. Clifford was lawful and was not a campaign contribution or a campaign expenditure by anyone.” “[The payment was made] for the purpose of influencing the election.” Donald Trump’s spokespeople on whether he reimbursed Michael Cohen for the Stormy Daniels payment 2017 ’18 “None of these allegations are true.” —Sarah Sanders “[Trump] paid him back. No campaign finance violations, no crime of any kind. Michael had discretion to solve these.” —Rudy Giuliani Pete Marovich/Getty Images Donald Trump on what kind of work Michael Cohen did for him 2017 ’18 “Michael is my attorney.” “He represented me on very small things. He was like a public-relations person.”

Mr. Howard told Mr. Davidson that Ms. McDougal should get back in touch if she found any evidence of the alleged affair.

After the meeting, Messrs. Pecker and Howard learned Ms. McDougal had also been meeting with investigative reporters at ABC News about sharing her story in a televised interview.

Mr. Cohen updated Mr. Trump on developments throughout. The ABC talks prompted American Media to offer to buy Ms. McDougal’s story for $150,000 in early August.

The contract gave the publisher the exclusive rights to her story, and guaranteed Ms. McDougal and American Media two magazine covers on which she would appear as a model. As part of the deal, American Media had the option of publishing health and fitness columns under Ms. McDougal’s name.

In a Skype call, Mr. Howard told Ms. McDougal the covers and columns would help resuscitate her modeling career.

Mr. Pecker researched campaign-finance laws before entering into the McDougal deal. The question was: Would American Media’s payment amount to an illegal campaign contribution to Mr. Trump? Corporations are barred under federal law from giving directly to candidates, either in cash or in-kind contributions.

After speaking with an election-law specialist, Mr. Pecker concluded the company’s payment to Ms. McDougal wouldn’t violate the law, because the magazine covers and health columns gave him a business justification for the deal.

The contract had an effective date of Aug. 5, 2016. Ms. McDougal signed it the following day.

Mr. Cohen assured Mr. Pecker that Mr. Trump would reimburse the publisher, and they began to devise a repayment plan at the end of that month.

‘All the stuff’

Concerned Mr. Pecker might leave American Media, Mr. Cohen wanted to buy other materials the company had gathered on Mr. Trump over the years, including source files and tips. In a meeting at the Trump Organization offices in early September, Mr. Cohen told Mr. Trump of his plan.

Mr. Cohen, who complained to associates about Mr. Trump’s frugality, was also worried his boss would balk at reimbursing Mr. Pecker. He secretly recorded Mr. Trump discussing the deal.

“Um, I need to open up a company for the transfer of all of that info regarding our friend, David, you know, so that—I’m going to do that right away,” said Mr. Cohen, according to a copy of the audio file.

As Mr. Cohen explained his plans, Mr. Trump spoke over him: “So, what are we gonna pay…One-fifty?” Mr. Trump asked. Mr. Cohen paused and replied, “Yes.”

Mr. Cohen said he would be getting “all the stuff,” meaning the other files on Mr. Trump he had been seeking. They discussed the uncertainty about what might become of the files if Mr. Pecker no longer ran American Media. “Yeah, I was thinking about that,” Mr. Trump said. “Maybe he gets hit by a truck.”

Messrs. Pecker and Cohen signed a contract for the transfer of the McDougal story in late September. Mr. Cohen set up a shell company in Delaware for the transaction on Sept. 30.

The publisher would assign the rights to Ms. McDougal’s story to Mr. Cohen for $125,000—the value they put on Ms. McDougal’s agreement with American Media minus the magazine covers and fitness columns, the rights to which the publisher would retain.

Mr. Pecker called off the Trump-reimbursement deal in October 2016 on the advice of his lawyer. Accepting reimbursement from Mr. Trump, the executive worried, could undermine any argument that the McDougal payment was made for editorial and business reasons, rather than as an in-kind campaign contribution.

Mr. Pecker told Mr. Cohen to tear up the reimbursement agreement, but Mr. Cohen kept a copy. Federal agents found it in a search of Mr. Cohen’s office earlier this year.

Stormy surfaces

As the McDougal deal came together, another woman was shopping her story of an alleged tryst with Mr. Trump.

Earlier in 2016, an agent for Ms. Clifford, the adult-film actress, had approached Mr. Howard about selling her story of a sexual encounter with Mr. Trump. The agent, Gina Rodriguez , was seeking upward of $200,000 for the story, but Mr. Howard passed.

Ms. Clifford’s story—she said she had sex with Mr. Trump at a celebrity golf tournament in Lake Tahoe a decade earlier—had already been told in 2011 on a gossip blog, The Dirty. Mr. Howard reminded Ms. Rodriguez that Ms. Clifford had called the report “bulls—” when contacted five years earlier by entertainment channel E!.

Ms. Clifford gained more leverage on Oct. 7, when the Washington Post published previously unaired footage from a 2005 appearance by Mr. Trump on NBC’s “Access Hollywood.” Mr. Trump could be heard on the video chatting with host Billy Bush about groping women.

After the tape surfaced, nearly upending Mr. Trump’s campaign, Ms. Rodriguez reached out to Mr. Howard and told him Ms. Clifford was prepared to go public. Ms. Clifford, through her agent, was in preliminary talks with ABC’s “Good Morning America.”

Brendan McDermid/REUTERS Michael Cohen on whether he is loyal to Donald Trump 2017 ’18 “I’m the guy who would take a bullet for the president.” “My wife, my daughter and my son have my first loyalty and always will.” Mark Wilson/Getty Images Donald Trump on whether he knew about the payment to Stormy Daniels 2017 ’18 Did you know about the $130,000 payment to Stormy Daniels? “No.” Do you know where he got the money to make that payment? “No, I don’t know.” “Mr. Cohen, an attorney, received a monthly retainer, not from the campaign and having nothing to do with the campaign, from which he entered into, through reimbursement, a private contract between two parties.” Mary Altaffer/AP Photo Michael Cohen on why he paid Stormy Daniels, whose given name is Stephanie Clifford 2017 ’18 “The payment to Ms. Clifford was lawful and was not a campaign contribution or a campaign expenditure by anyone.” “[The payment was made] for the purpose of influencing the election.” Donald Trump’s spokespeople on whether he reimbursed Michael Cohen for the Stormy Daniels payment 2017 ’18 “None of these allegations are true.” —Sarah Sanders “[Trump] paid him back. No campaign finance violations, no crime of any kind. Michael had discretion to solve these.” —Rudy Giuliani Pete Marovich/Getty Images Donald Trump on what kind of work Michael Cohen did for him 2017 ’18 “Michael is my attorney.” “He represented me on very small things. He was like a public-relations person.”

Mr. Howard alerted Mr. Pecker, and they separately spoke to Mr. Cohen about Ms. Clifford. The Trump camp at the time was scrambling to contain fallout from the tape, as women came forward with stories of sexual misconduct by the candidate, all of which he denied.

Ms. Clifford had taken a polygraph test in 2011, when another celebrity publication, Life & Style, was vetting her claims of a sexual encounter. When asked whether she had unprotected sex with Mr. Trump, she answered “yes,” and the examiner found no signs of deception.

Mr. Cohen had been able to kill that earlier story with a legal threat. Ms. Clifford and Ms. Rodriguez wouldn’t be intimidated this time.

Mr. Cohen asked American Media to buy Ms. Clifford’s story. Mr. Pecker refused on the grounds that he didn’t want his company to pay a porn star.

Messrs. Cohen and Trump would have to handle the payment themselves. Mr. Cohen told federal prosecutors he relayed the news to Mr. Trump in his Trump Tower office in the second week of October 2016.

That is when Mr. Trump, smarting from the “Access Hollywood” tape, told Mr. Cohen to “get it done,” according to Mr. Cohen’s account to prosecutors.

Within days, Mr. Cohen and Mr. Davidson had negotiated a nondisclosure agreement for Ms. Clifford.

The money was slow in coming because Mr. Trump, Mr. Cohen and the longtime chief financial officer of the Trump Organization, Allen Weisselberg , couldn’t settle on a plan for getting it to Mr. Davidson without anyone being able to trace it back to Mr. Trump, according to Mr. Cohen’s account to prosecutors. Among the options they considered: routing the payment through a Trump-owned property, Mr. Cohen told prosecutors.

Mr. Cohen offered a suggestion: Why not have Mr. Weisselberg make the payment? “You’re the CFO,” he told the longtime Trump aide, according to Mr. Cohen’s account to prosecutors. “You pay this.” Mr. Weisselberg said he couldn’t come up with the money.

Mary Mulligan, a lawyer for Mr. Weisselberg, said he had been “fully cooperative” with the investigation and declined to comment further. A person close to Mr. Weisselberg disputed the account Mr. Cohen gave to prosecutors.

Mr. Cohen had told Mr. Davidson to expect a $130,000 wire transfer by Oct. 14, but missed the deadline, as well as an extension, prompting Ms. Clifford to walk away.

While Mr. Cohen considered a path forward, he offered excuses to Ms. Clifford’s camp. He told Mr. Davidson banks were closed for the Jewish holidays and he couldn’t reach Mr. Trump on the campaign trail. “My guy is in five states today,” Mr. Cohen said.

Mr. Davidson told Mr. Howard on Oct. 25, 2016, that Ms. Clifford would soon speak publicly. Mr. Howard texted Mr. Cohen that they needed to coordinate “or it could look awfully bad for everyone.”

In a tense three-way call on an encrypted app, Messrs. Pecker and Howard urged Mr. Cohen to complete the deal before Ms. Clifford disclosed the hush-money negotiations.

Out of options and time, Mr. Cohen decided to cover the payment himself. “F— it, I’m just going to do it,” he told Mr. Davidson in a phone call.

He drew down his home-equity line and transferred $130,000 to Mr. Davidson on Oct. 27. Ms. Clifford signed a fresh nondisclosure agreement the next day.

That month, a news site called “The Smoking Gun” published an account of Ms. Clifford’s alleged sexual encounter with Mr. Trump. Then-Republican National Committee chairman Reince Priebus and Trump campaign chief Steve Bannon confronted the candidate. Mr. Trump told them the encounter never happened.

Four days before the 2016 election, The Wall Street Journal revealed the $150,000 payment to Ms. McDougal by American Media. The company said at the time Ms. McDougal had been paid for magazine covers and fitness columns and denied buying her story to protect Mr. Trump.

The Trump campaign professed ignorance. “We have no knowledge of any of this,” Hope Hicks , Mr. Trump’s spokeswoman, said of the McDougal deal. Ms. Hicks, who discussed the matter with Mr. Trump before issuing the comment, was relaying what she had been told, according to people familiar with the conversation. She also denied Mr. Trump had sex with Ms. McDougal.

As Mr. Trump headed to victory on Nov. 8, Mr. Howard joined Mr. Cohen at the candidate’s election night celebration at the New York Hilton.

Repaying Cohen

Later that month, after Mr. Trump’s election win, Mr. Cohen met with Mr. Weisselberg to discuss reimbursement for the payment to Ms. Clifford, Mr. Cohen has told federal prosecutors.

Brendan McDermid/REUTERS Michael Cohen on whether he is loyal to Donald Trump 2017 ’18 “I’m the guy who would take a bullet for the president.” “My wife, my daughter and my son have my first loyalty and always will.” Mark Wilson/Getty Images Donald Trump on whether he knew about the payment to Stormy Daniels 2017 ’18 Did you know about the $130,000 payment to Stormy Daniels? “No.” Do you know where he got the money to make that payment? “No, I don’t know.” “Mr. Cohen, an attorney, received a monthly retainer, not from the campaign and having nothing to do with the campaign, from which he entered into, through reimbursement, a private contract between two parties.” Mary Altaffer/AP Photo Michael Cohen on why he paid Stormy Daniels, whose given name is Stephanie Clifford 2017 ’18 “The payment to Ms. Clifford was lawful and was not a campaign contribution or a campaign expenditure by anyone.” “[The payment was made] for the purpose of influencing the election.” Donald Trump’s spokespeople on whether he reimbursed Michael Cohen for the Stormy Daniels payment 2017 ’18 “None of these allegations are true.” —Sarah Sanders “[Trump] paid him back. No campaign finance violations, no crime of any kind. Michael had discretion to solve these.” —Rudy Giuliani Pete Marovich/Getty Images Donald Trump on what kind of work Michael Cohen did for him 2017 ’18 “Michael is my attorney.” “He represented me on very small things. He was like a public-relations person.”

While Mr. Cohen waited, he asked Mr. Pecker to lobby Mr. Trump to pay him more money.

Mr. Pecker visited Trump Tower twice during the presidential transition. When he raised Mr. Cohen’s request during a meeting in the first week of December 2016, Mr. Trump demurred, saying Mr. Cohen had plenty of money. During Mr. Pecker’s second visit, in January 2017, Mr. Trump thanked him for suppressing the McDougal story.

Mr. Weisselberg soon completed the reimbursement plan.

It would turn out to be a costly deal for Mr. Trump.

Had he just paid the ex-adult film star himself, Mr. Trump would have been out of pocket $130,000. Instead, Mr. Weisselberg authorized a reimbursement of twice that much, characterized in Mr. Trump’s records as legal fees, to cover the income tax hit Mr. Cohen would take. He also added a $60,000 bonus. Mr. Cohen received the money in monthly installments of $35,000.

In the first year of Mr. Trump’s presidency, American Media continued to feature him on the Enquirer cover. In July 2017, Mr. Trump hosted Messrs. Pecker and Howard at the White House for dinner, an Oval Office visit and a private tour of the Lincoln Bedroom led by the president.

After the Journal reported on the payment to Ms. Clifford in January 2018, the relationships between Messrs. Trump, Cohen and Pecker began to fracture.

Ms. Clifford, initially willing to keep quiet, began to seek more exposure and threatened to break the agreement after Mr. Cohen acknowledged paying her in a February statement to the news media. Mr. Trump instructed Mr. Cohen to coordinate with his son Eric Trump to silence Ms. Clifford in arbitration. It didn’t work; Ms. Clifford ignored the arbitrator’s restraining order.

Mr. Cohen continued to insist he had done the deal with Ms. Clifford on his own, while Mr. Trump said he knew nothing about it when talking to reporters on Air Force One on April 5.

“You’ll have to ask Michael Cohen,” the president said. “Michael is my attorney.”

Days later, on April 9, the Federal Bureau of Investigation raided Mr. Cohen’s office, apartment and hotel room. Agents approached Messrs. Pecker and Howard. Federal prosecutors subpoenaed American Media and the Trump Organization, among others.

Brendan McDermid/REUTERS Michael Cohen on whether he is loyal to Donald Trump 2017 ’18 “I’m the guy who would take a bullet for the president.” “My wife, my daughter and my son have my first loyalty and always will.” Mark Wilson/Getty Images Donald Trump on whether he knew about the payment to Stormy Daniels 2017 ’18 Did you know about the $130,000 payment to Stormy Daniels? “No.” Do you know where he got the money to make that payment? “No, I don’t know.” “Mr. Cohen, an attorney, received a monthly retainer, not from the campaign and having nothing to do with the campaign, from which he entered into, through reimbursement, a private contract between two parties.” Mary Altaffer/AP Photo Michael Cohen on why he paid Stormy Daniels, whose given name is Stephanie Clifford 2017 ’18 “The payment to Ms. Clifford was lawful and was not a campaign contribution or a campaign expenditure by anyone.” “[The payment was made] for the purpose of influencing the election.” Donald Trump’s spokespeople on whether he reimbursed Michael Cohen for the Stormy Daniels payment 2017 ’18 “None of these allegations are true.” —Sarah Sanders “[Trump] paid him back. No campaign finance violations, no crime of any kind. Michael had discretion to solve these.” —Rudy Giuliani Pete Marovich/Getty Images Donald Trump on what kind of work Michael Cohen did for him 2017 ’18 “Michael is my attorney.” “He represented me on very small things. He was like a public-relations person.”

As Mr. Trump continued to distance himself from Mr. Cohen and the payment, American Media turned on Mr. Cohen, with a National Enquirer cover featuring the headline, “Trump Fixer’s Secrets & Lies.” Mr. Cohen learned he had been let go as Mr. Trump’s personal attorney when he saw it on television.

Both Messrs. Cohen and Pecker began seeking to minimize their exposure. Mr. Pecker, granted immunity for his grand jury testimony, told investigators about Mr. Trump’s involvement in the McDougal deal.

Three years after Mr. Pecker promised to work with Mr. Cohen to help Mr. Trump, the deals they made have unraveled. Ms. McDougal and Ms. Clifford have both been let out of their hush agreements after filing lawsuits.

The three men no longer speak to one another.

Write to Joe Palazzolo at joe.palazzolo@wsj.com, Nicole Hong at nicole.hong@wsj.com, Michael Rothfeld at michael.rothfeld@wsj.com, Rebecca Davis O’Brien at Rebecca.OBrien@wsj.com and Rebecca Ballhaus at Rebecca.Ballhaus@wsj.com