Both men have gobs of money.

They didn’t make it the old-fashioned way, with steel and brick, but instead with big, disruptive, life-changing ideas.

After they got rich, after they’d achieved a titan status imaginable only in the digital age, that’s when the tabloids came for them.

And that’s when they went to war.

Theirs is a tale of two billionaires — Jeffrey P. Bezos of fame and Peter Thiel, who birthed PayPal. So different in style and temperament, the two men have each found their sex lives splashed in public against their wills in separate tabloid “gotchas.” But they have tangled with the merchants of salacity in completely opposite ways.

American Media denies claims that it used threats of lewd photos in an attempt to extort Amazon chief executive and Washington Post owner Jeffrey P. Bezos.

Bezos, who also owns The Washington Post, blasted his disdain into the maw of the Internet, essentially delivering the equivalent of a lawyer’s opening statement with the entire planet sitting in the jury box. Thiel operated in sotto voce fashion, secretly maneuvering to exact revenge and not surfacing until he had triumphed.

Bezos is locked in a conflict with the National Enquirer, which last month published intimate text messages he’d sent to Lauren Sanchez, with whom he was having an extramarital affair, and photos of them together. In a Medium post Thursday, Bezos accused the supermarket tabloid, which is owned by American Media Inc., of blackmail and extortion for threatening to publish additional intimate photographs if he and his representatives did not agree to stop their investigation of how the material was obtained. Bezos suggested that the tabloid, whose parent company is run by a friend of President Trump, had political motives to run stories about his affair. Trump has frequently attacked Bezos over his ownership of The Post.

Thiel’s battle took place against Gawker, the sassy and sometimes raunchy website that earned his eternal enmity by outing him as gay in 2007. He got back at the site in 2016 when he surreptitiously funded a successful lawsuit by Terry Bollea, better known as the wrestler Hulk Hogan, over the site’s 2012 publication of a tape depicting Bollea having sex. Gawker went out of business after a jury awarded $140 million in damages.

“They are two fundamentally different approaches to similar problems,” said Ryan Holiday, author of “Conspiracy: Peter Thiel, Hulk Hogan, Gawker, and the Anatomy of Intrigue.”

When Thiel’s involvement in the Bollea case was revealed, Bezos was less than enthusiastic about his fellow tech titan’s actions. At a conference in June 2016, Bezos was asked about the Thiel-Gawker slugfest. He responded with an old saying: “Seek revenge and you should dig two graves, one for yourself.”

“Is that really how you want to spend your time?” Bezos went on to say. “As a public figure, the best defense to speech that you don’t like is to develop a thick skin.”

Those remarks came to mind for Bezos watchers after his posting on Medium, a self-publishing website.

“It did make me think he was reconsidering that position,” said Holiday, who also works as a media strategist.

But was he?

In the first paragraph of Bezos’s post, he frames his decision to publicize letters he had received from the National Enquirer as evidence of wrongdoing — a step beyond berating the tabloid for publishing details of his private life.

“Rather than capitulate to extortion and blackmail, I’ve decided to publish exactly what they sent me, despite the personal cost and embarrassment they threaten,” Bezos wrote.

The saga is drenched in a hailstorm of theories and counter-theories. Bezos’s team, headed by famed security consultant Gavin de Becker, has cast a suspicious eye on Michael Sanchez regarding the leak of the texts and photos. Sanchez is the brother of Bezos’s girlfriend, former TV host Lauren Sanchez. Michael Sanchez is a Trump supporter, and his potential involvement is part of a theory that the leak is a political hit.

Michael Sanchez has denied involvement and suggested that de Becker might be involved, supposedly in an effort to destroy the relationship between Bezos and his sister and repair the Amazon founder’s marriage to MacKenzie Bezos.

Both Sanchez and de Becker have, at times, explored the possibility that the text messages were obtained by a foreign government or a business competitor, according to interviews and a Post review of emails and text messages. Sanchez has even posited that Israel’s Mossad, British intelligence or the U.S. National Security Agency might be involved. (De Becker ultimately concluded that hacking was not involved.)

The Post’s reporting on the private leak investigation seemed to have played a role in National Enquirer’s decision to approach Bezos. According to one of the letters Bezos posted on Medium, Dylan Howard, a top editor at the tabloid, cited The Post’s examination of the political hit-job theory and said he was prepared to publish additional photos of Bezos and Lauren Sanchez.

Publishing the letters, without redacting the detailed list of images, was a move by Bezos that fit into one of the credos of the crisis management business: Get out in front of a negative story.

“It’s always better to define yourself than let the other side define you,” said Diana Banister, a veteran Washington crisis communications specialist with Shirley & Banister Public Affairs.

It may have been a smart strategy, Banister said, but the execution wasn’t perfect. Banister thought Bezos’s tone, at times, dripped with “snarkiness.” She also thinks Bezos’s letter was overly complex, noting his decision to raise the possibility that the National Enquirer’s relationship with Saudi Arabia might have something to do with the sequence of events. The Post has reported that the CIA has concluded that Saudi Arabian Crown Prince Mohammed bin Salman ordered the brutal murder of Post contributing columnist Jamal Khashoggi. The Enquirer had raised eyebrows by publishing a glowing special edition about the crown prince.

The Enquirer has adamantly denied being motivated by politics to publish the Bezos texts and photos.

Bezos, de Becker and an Amazon spokesman declined to comment for this article.

Bezos and Thiel both see their battles as achieving some greater good.

Thiel has decried the fact that even a wealthy person, such as Bollea, needed his financial help to take on a tabloid. Bezos struck a similar note in his Medium post, writing, “If in my position I can’t stand up to this kind of extortion, how many people can?”

As described by Holiday, Thiel considered various approaches, including hiring a lobbyist, after Gawker’s piece outing him.

“He settled on a legal strategy in secret as a way of settling the score,” Holiday said.

Thiel thought he needed an “element of surprise,” Holiday said, and figured funding Bollea’s lawsuit was the “best way to put an end to what he felt was someone acting outside the bounds of human decency.”

Thiel’s covert assault on Gawker has drawn criticism that cites the dangers of wealthy individuals dictating who is allowed to produce news. But Thiel has rejected those broadsides, saying that Gawker was a unique case.

“It is ridiculous to claim that journalism requires indiscriminate access to private people’s sex lives,” Thiel wrote in an August 2016 column in the New York Times. “A free press is vital for public debate. Since sensitive information can sometimes be publicly relevant, exercising judgment is always part of the journalist’s profession. It’s not for me to draw the line, but journalists should condemn those who willfully cross it.”

Less than a week after that column was published, a notice appeared on Gawker’s website.

“ is shutting down today, Monday 22nd August, 2016, some 13 years after it began and two days before the end of my forties,” wrote editor Nick Denton. “It is the end of an era.”

Thiel had won.

Now the question hangs in the air: Will Bezos? And what would a Bezos win look like?

“Jeff Bezos is being courageous in exposing the unseemly practices of American Media and its titles, including the National Enquirer,” Charles Harder, a high-powered attorney who represented Bollea in the Gawker suit, wrote Friday in an email to The Post. “The company publishes dozens of supermarket magazines and online publications which millions of Americans read. (Perhaps not for long.)”