When the National Enquirer published explicit text messages between Amazon founder Jeffrey P. Bezos and the woman he was having an affair with, the world’s richest man made clear he wanted to find out how the tabloid got hold of his private communications.

Bezos commissioned an investigation into the Enquirer’s investigation of his love life, thereby leaping into a roiling mix of political attacks and conspiracy theories featuring the president of the United States, key figures in special counsel Robert S. Mueller III’s probe of Russian interference in the 2016 election, minor Hollywood celebrities and the owner of The Washington Post, Bezos himself.

Depending on whom you believe, the Enquirer’s exposé on Bezos’s affair was a political hit inspired by President Trump’s allies, an inside job by people seeking to protect Bezos’s marriage, or no conspiracy at all, simply a juicy gossip story.

The saga might have been easily dismissed as little more than tabloid fare, but it has taken on a more serious cast in recent days. A volley of charges and countercharges about how and why the Enquirer launched its investigation has emerged for several reasons, including the history of the Enquirer, which has acknowledged taking actions during the last presidential campaign that benefited Trump politically. Trump, meanwhile, has repeatedly lodged attacks on The Post’s coverage of him and on Bezos, who bought the news company in 2013. And Bezos, the head of a retail giant that is famously loath to comment to the media, has authorized his security chief to speak about his investigation.

Bezos’s longtime private security consultant, Gavin de Becker, has concluded that the billionaire was not hacked. Rather, de Becker said in an interview, the Enquirer’s scoop about Bezos’s relationship with former TV anchor Lauren Sanchez began with a “politically motivated” leak meant to embarrass the owner of The Post — an effort potentially involving several important figures in Trump’s 2016 campaign.

As the Daily Beast first reported last week, de Becker has publicly named only one subject of his investigation, Michael Sanchez, Lauren’s brother and a pro-Trump Hollywood talent manager who is also an acquaintance of provocative Trump backers Roger Stone and Carter Page.

“We are studying many people who might have been involved in this, and Michael Sanchez is one we’ve spoken with and been looking at,” de Becker told The Post.

But de Becker — who provided security for President Ronald Reagan’s guests and whose private security firm is popular among celebrities — is not the only one looking into who leaked the text messages to the Enquirer.

Michael Sanchez, whose Twitter feed colorfully defends Trump and slams reporting critical of the president as “fake news,” said in an interview that he has launched his own investigation into the origin of the Enquirer’s story and has sought advice from Stone and Page about the security of text and phone communications.

Stone, a longtime Republican operative and Trump adviser, has pleaded not guilty to charges of lying to Congress and witness tampering. Page is a former Trump campaign foreign policy adviser whose trips to Moscow have drawn scrutiny from congressional investigators.

Sanchez firmly denies playing any role in the revelation of his sister’s affair. He said in interviews with The Post that his priorities are to protect his sister’s relationship with Bezos and “to clear my name by telling the truth.”

Sanchez said he was told by multiple people at American Media, the Enquirer’s parent company, that the Enquirer set out to do “a takedown to make Trump happy.”

Through a spokesman, the company declined to comment on how the tabloid obtained the text messages but said that “American Media emphatically rejects any assertion that its reporting was instigated, dictated or influenced in any manner by external forces, political or otherwise. End of speculation — and story.”

Sanchez, who said he is his sister’s manager and publicist, said he learned of the affair last spring and first met Bezos on April 20 at a dinner with Lauren Sanchez, Bezos and others at a Hollywood restaurant, the Hearth and Hound. Michael Sanchez said he has socialized with Bezos and his sister multiple times during their relationship.

In the aftermath of the Enquirer story, Sanchez offered a variety of theories to explain how texts between Bezos and his sister made their way to the tabloid, including spying by foreign governments, rival tech companies or “deep state” actors within the U.S. government, according to a compilation of emails between Sanchez and de Becker that were provided to The Post.

In a Jan. 21 email to de Becker, Sanchez offered a “brief summary of the info I gathered from Carter [Page] and Roger [Stone]” and included links to news articles that outlined the National Security Agency’s ability to collect metadata on phone calls.

Both de Becker and Sanchez at various points theorized that government or foreign hacking could have been behind the leak of Bezos’s texts, according to email and text exchanges between the two. Sanchez discussed with de Becker a theory in which Trump might have enlisted the help of British intelligence or the Israeli Mossad.

Now, as de Becker has cast suspicion on Sanchez, Sanchez is hitting back.

In a written statement to The Post, Sanchez accused de Becker of “lies, half-truths, sloppy tabloid leaks, [and] crazy conspiracy theories.” Sanchez said de Becker sought to finger him as the source of leaks because de Becker wanted to deflect attention from his own failure to protect Bezos.

Sanchez said he believed de Becker, Bezos’s security chief for two decades, was involved in the leaks to the Enquirer “to sabotage Mr. Bezos and Ms. Sanchez’s love affair.” The brother argued that de Becker was trying to keep Bezos and his wife of 25 years, MacKenzie Bezos, together.

Michael Sanchez said de Becker has asserted a “strange control” over Bezos and Lauren Sanchez and has “forced” the two to stay physically apart from each other since the Enquirer’s article appeared.

Jay Carney, Amazon’s senior vice president for global corporate affairs, declined The Post’s request for an interview with Bezos.

Lauren Sanchez also declined to comment, according to her representative.

Bezos and Trump — two wealthy business executives who became famous as billionaire disrupters upending the worlds of retailing and politics — have traded Twitter barbs in the past. And Trump often lumps Bezos’s separate ventures, Amazon and The Post, together in an effort to discredit the newspaper’s reporting.

Bezos’s ownership of The Post was highlighted on the cover of the unusual, 12-page spread on the Bezos-Sanchez affair that the Enquirer published last month.

The Enquirer reported that it spent four months on what it called the “largest investigation” in its history, following Bezos and Lauren Sanchez “across five states and 40,000 miles . . . in private jets, swanky limos, helicopter rides, romantic hikes, [and] five-star hotel hideaways.”

Last July, Dylan Howard, American Media’s chief content officer, saw a photo of Lauren Sanchez standing next to Bezos on the VIP viewing platform for a rocket launch by Bezos’s space exploration company, Blue Origin, and decided to look into a relationship between Bezos and Sanchez, according to a person who spoke to Howard at the time.

Howard declined to comment to The Post. Howard’s byline appears with that of other Enquirer reporters atop the paper’s articles about the Bezos affair.

The salacious report came as prosecutors have examined the Enquirer’s role in helping Trump. In September, federal prosecutors reached an agreement with American Media in which the company, chief executive David Pecker and Howard, his top deputy, would cooperate with authorities and acknowledge that the Enquirer worked with the Trump campaign to kill stories “about the presidential candidate’s relationships with women.”

According to three people familiar with the tabloid’s discussions, the Enquirer was ready to publish a story on Bezos and Lauren Sanchez in early autumn but held off because Pecker, a longtime associate and supporter of the president, wanted to wait until after the midterm elections and did not want to feed the public impression that he was a tool for Trump. One of those people said the Enquirer published only when it was confident in its reporting.

During the 2016 campaign, Enquirer executives sent pre-publication digital copies of articles and pictures related to Trump to the candidate’s attorney, Michael Cohen, The Post reported last year. Cohen has said part of his job was trying to head off negative reporting about Trump. The Enquirer denied ever sharing such material ahead of publication.

In 2016, American Media bought former Playboy model Karen McDougal’s account about her alleged affair with Trump for $150,000 — not to publish the story but to kill it.

De Becker said his investigation ended up focusing on political motives for the Enquirer report because “I would be blind if I didn’t register the fact that Michael Sanchez is an associate of people like Roger Stone, Carter Page and Scottie Nell Hughes,” a frequent TV surrogate for Trump during the campaign.

“Learning that was a major surprise in our investigation,” de Becker said. “Naturally, that raised questions about whether [Enquirer publisher] David Pecker, the National Enquirer and others intended to do a hit piece on The Washington Post and Jeff Bezos.”

Stone, Page and Hughes denied to The Post that they had any role in exposing Bezos’s affair.

The Post also has a business relationship with de Becker; one of the security consultant’s employees serves as the newspaper’s director of security at its Washington headquarters, according to Kristine Coratti Kelly, The Post’s vice president for communications.

The Post’s relationship with de Becker’s company “allows us to utilize their vast resources and training programs rather than trying to build them in-house,” Kelly said.

Michael Sanchez said he spoke to Stone and Page about his sister’s relationship with Bezos only after the tabloid published its exposé. Early last fall, Michael Sanchez told a political acquaintance that his sister and Bezos were traveling together, according to a person familiar with the conversation.

Over the past month, a behind-the-scenes PR battle has raged as each side has sought to push back against critical media accounts and to promote reporting that favors its version of how the Enquirer story came to be.

On Jan. 7, Bezos and Lauren Sanchez received almost identical emails from the Enquirer, Howard and his deputy, James Robertson, American Media’s news director, according to copies of the emails obtained by The Post.

“I write to request an interview with you about your love affair,” the messages read. The Enquirer asked Bezos and Sanchez to respond to dozens of questions.

Michael Sanchez told The Post that, acting as his sister’s representative, he agreed to meet with Howard at American Media’s offices in New York to review the Enquirer’s reporting.

On the morning of Jan. 9, Bezos tweeted an announcement that he and wife MacKenzie Bezos “have decided to divorce and continue our shared lives as friends.”

The announcement surprised Michael Sanchez and enraged Howard, who felt, according to two people who spoke to him at the time, that Bezos had preempted his scoop.

After the Bezos tweet, the Enquirer, which was not due to publish its next edition until Jan. 16, rushed its report about the affair into print a week early, allowing it to appear on newsstands Jan. 10, according to a person familiar with the Enquirer’s work on the report.

The Enquirer article led quickly to dueling investigations and lawsuit threats.

Documents obtained by The Post show that attorneys for American Media sought to persuade the Daily Beast not to publish its initial report suggesting that Trump’s allies may have been involved in the effort to expose the Bezos affair. According to a draft legal complaint, Enquirer attorneys threatened to sue the Daily Beast if it used any information provided by a former Enquirer executive who had been hired by the website.

The Daily Beast published two articles about the affair last week. Its editor did not respond to a request for comment.

Stone, whose campaign trickery has been the stuff of movies, books and political folklore since Richard Nixon’s 1972 presidential campaign, had sought to preempt the Beast’s stories. On Jan. 29, the day of his arraignment in the Mueller probe, Stone appeared on Infowars, the conspiracy-minded Internet talk show run by Alex Jones.

“Breaking news here,” Stone said. He claimed, incorrectly, that the Beast would report that “I, working with President Trump and the NSA, hacked the cellphone of Lauren Sanchez, the paramour of Jeff Bezos — or that we hacked Bezos’s cellphone and that we gave the information to the National Enquirer. This is a conspiracy that allegedly involves Michael Sanchez — Lauren Sanchez’s brother, a very hot Hollywood manager, [who] happens to be a friend of mine.”

Meanwhile, de Becker’s attorneys have discouraged tabloids such as the New York Post and the Sun in London from reporting Michael Sanchez’s assertion that the leak to the Enquirer resulted from de Becker’s failure to protect Bezos’s privacy, according to documents obtained by The Post. An attorney for de Becker also threatened legal action against American Media over the same issue, the documents show.

The complex web of purported explanations for the Enquirer’s focus on Bezos’s love life was, Stone asserted, an example of “the insanity of the left.”

As Stone tells it, he got involved with the Bezos story only last month, just days before his arrest, when he got a phone call from the West Coast.

On the line was John Phillips, a talk-show host at KABC radio in Los Angeles. Phillips had interviewed Stone numerous times, and they had become friends, getting together periodically for dinners, Stone said, speaking in detail about the Bezos matter for the first time.

Phillips, who declined to comment for this report, was not calling to arrange a meal but to see whether Stone would talk with his manager and friend, Michael Sanchez. Suspecting that his sister had been under surveillance, he wanted to talk to people he thought of as experts on how that is done, such as Stone and Page, according to Stone.

Michael Sanchez helped Page land a gig speaking in October at Politicon, a nonpartisan political convention, in a discussion titled “Sex, Spies and Videotape: Russian Hysteria in Context.”

Page and Sanchez spoke about business opportunities and developed a friendly relationship, Page said Monday. But Page said he did not learn that his new friend had a sister who was involved with the world’s richest man until the Enquirer report appeared.

When reports began appearing suggesting that Sanchez might be responsible for the leaks, Page said he saw a parallel to his own experience. “I think there are a lot of similar lessons learned,” he said.

Page contended to Sanchez that he became embroiled in the Russia investigation because someone was out to get Trump. Page told Sanchez that something similar might be happening to him.

“Realize that people have agendas,” Page recalled telling Sanchez. “There are bigger fish whose reputations they are trying to fry in the media.”

Meanwhile, the Enquirer report led de Becker and Sanchez to conduct a lengthy text exchange, and de Becker appeared incredulous that Sanchez was consulting with Stone.

“Do you really know Roger Stone?” de Becker asked.

Not long afterward, Sanchez told Stone about de Becker’s theory of what happened. In this telling, de Becker posited that since there was no evidence that Bezos’s or Lauren Sanchez’s phones had been hacked, the information could only have been extracted by the government. Sanchez claimed that de Becker believed Trump had a vendetta against Bezos because of his ownership of The Post and because Bezos is a “big opponent of Donald Trump,” Stone said.

Stone said he thought the scenario Sanchez spelled out was “crazy. Just crazy.” Stone’s theory about the leak to the Enquirer was one that Michael Sanchez also offered — that de Becker hadn’t protected Bezos’s communications, so he needed someone to blame and came up with the notion of a political hit job.

De Becker stood by his theory. “This inquiry has been about crime, not journalism,” he said. “Again and again, political motives became evident.”

For his part, Stone said he was not surprised to become embroiled in the Bezos story.

“At the moment, I’m a very convenient punching bag — for obvious reasons,” Stone said Friday, hours after he was in federal court for a hearing on the charges against him, of lying to Congress and witness tampering.