By Deepa Seetharaman, Emily Glazer and Tim Higgins

Facebook Inc. Chief Executive Mark Zuckerberg has groused for years that Apple Inc. and its leader, Tim Cook, have too much sway over the social-media giant's business. In 2018, his anger boiled over.

Facebook was embroiled in controversy over its data-collection practices. Mr. Cook piled on in a national television interview, saying his own company would never have found itself in such a jam. Mr. Zuckerberg shot back that Mr. Cook's comments were "extremely glib" and "not at all aligned with the truth."

In private, Mr. Zuckerberg was even harsher. "We need to inflict pain," he told his team, for treating the company so poorly, according to people familiar with the exchange.

It wasn't the first time -- or the last -- that Mr. Cook's comments and actions would leave Mr. Zuckerberg seething and, at times, plotting to get back at Apple. The escalation of grievances erupted late last month in a rare public tit-for-tat between the two tech giants that laid bare the simmering animosity between their leaders, who exchanged jabs about privacy, app-tracking tools and, ultimately, their dueling visions about the future of the internet.

Apple has positioned itself as the protector of digital privacy, upholding a greater good, while often leveling criticisms at Facebook's business model -- without naming the company. All of that grates on Facebook, which sees Apple as overreaching in a way that threatens Facebook's existence, and hypocritical, including by doing extensive business is China where privacy is scarce. A 2017 attempt to address tensions through a face-to-face meeting between the two CEOs resulted in a tense standoff.

The trigger last month was a new privacy tool the iPhone maker plans to roll out that will further restrict Facebook's ability to collect data. Mr. Zuckerberg accused Apple on an earnings call of using its platform to interfere with how Facebook apps work. Mr. Cook, without naming Facebook, delivered an online speech condemning "conspiracy theories juiced by algorithms" -- a jab that came just days after the Capitol riot.

At stake is how the internet will evolve and which companies will dominate it. Facebook and Apple's visions are diverging and increasingly incompatible. Facebook wants to capture and monetize eyeballs on every possible device and platform. Apple wants to draw users to its own hardware-centric universe, partly by marketing itself as a privacy-focused company. The outcome of the battle could affect what kinds of information users see when they browse the internet.

The war of words and ideas will ultimately play out in court, regulatory agencies and user decisions as both companies defend themselves against antitrust investigations. The potential regulatory settlements and legal decisions are likely to affect hundreds of millions of consumers' phones in coming years.

A Facebook spokeswoman, Dani Lever, said the choice between personalized services and privacy was a "false trade-off," and that Facebook provides both. "This is not about two companies. This is about the future of the free internet," she said, asserting that small businesses, app developers and consumers lose out under Apple's new rules. "Apple claims this is about privacy, but it's about profit, and we're joining others to point out their self-preferencing, anticompetitive behavior."

She denied that the dispute between the two companies is personal, and said that Facebook is "deliberately standing up to Apple" on behalf of businesses and developers hurt by the new policy.

An Apple spokesman declined to respond to Ms. Lever's comments.

Sen. Mike Lee of Utah, the leading Republican on the Senate antitrust subcommittee, said: "This feud sits at the nexus of privacy and antitrust. We don't want to impose regulation that just ends up protecting incumbents and entrenching monopolies. Facebook keeps voicing its support for 'internet regulation,' and it's not because it wants to help competition."

Advisers to the two companies, including law firms and lobbyists, are growing concerned that they won't be able to work for both tech giants, people who work for the firms said.

In personality terms, the two men differ greatly. Mr. Zuckerberg, 36 years old, is a hacker-turned-Harvard-dropout who once touted the end of privacy as a social norm. Mr. Cook, 60, who hails from Alabama, has been a deeply private man who rose through the company as a specialist in supply-chain logistics.

Mr. Zuckerberg built Facebook on the concept of radical openness, and he is determined to keep the company at the heart of global connectivity, with free services supported by targeted advertising. Some people familiar with Mr. Zuckerberg's thinking said he has taken Apple's broadsides personally, running the risk of distracting him at a time when Facebook is fighting many other battles in the U.S. and abroad over antitrust and content moderation.

Mr. Cook, former deputy to Apple co-founder Steve Jobs, plans to carve out an experience for users free of what he portrays as invasive tracking. His position on privacy, which harks back to the days of the late Mr. Jobs, is made somewhat easier by the fact that much of Apple's business comes from the sale of iPhones, iPads and computers, not ads.

As Apple and Facebook have evolved, they increasingly compete head-to-head in some areas. With iPhone sales possibly peaking, Mr. Cook has pushed Apple to bolster and develop digital services. Its iMessage chat system competes for user attention with Facebook offerings such as WhatsApp. Facebook is developing more hardware devices. Both companies are investing in payments systems.

Apple also receives billions of dollars a year from Alphabet Inc.'s Google , for making the search giant the default search engine on Apple's Safari browser. Google's profits are largely derived from the kind of data-gathering on users that Mr. Cook and other Apple leaders have sharply criticized Facebook for doing.

Publicly, Mr. Zuckerberg has identified Apple as one of Facebook's most formidable competitors. Privately, he and other Facebook employees have been waging a campaign against Apple, asserting in meetings and communications with government officials, antitrust regulators and advertisers that the company is abusing its power and deserves more regulatory scrutiny, according to people familiar with the matter.

On an earnings call in late January, Mr. Zuckerberg said: "Apple has every incentive to use their dominant platform position to interfere with how our apps and other apps work."

Apple has ratcheted up its privacy controls, preparing to roll out a new feature this spring that will allow users to limit the ability of apps to track what they are doing on their phones.

Late last month, in his online speech on International Privacy Day, Mr. Cook made clear where he stood, without naming Facebook. "If a business is built on misleading users, on data exploitation, on choices that are no choices at all, then it does not deserve our praise -- it deserves reform," he said.

Relations weren't always so strained. Back in 2014, when Mr. Cook seemed more focused on the business threat posed by Google's Android operating system, he called Facebook a "partner."

The rise of the smartphone, driven in large part to Apple's iPhone, led Facebook in 2012 into the world of mobile apps. As app use increased, new questions arose about user privacy. Already, Apple was working on the matter internally.

Before his death in 2011, Mr. Jobs had spoken publicly about the matter at an event held by The Wall Street Journal. "I believe people are smart, and some people want to share more data than other people do," he said. "Ask them. Ask them every time. Make them tell you to stop asking them if they get tired of asking them. Let them know precisely what you're going to do with their data."

Apple subsequently rolled out features and software aimed at making privacy features easier to use and more secure. It introduced the Touch ID fingerprint scanner in 2013 and new software in 2014 that encrypted users' photos, messages and other data in a way that meant the company could no longer extract the information from a locked phone.

The issue drew public attention after Edward Snowden leaked secrets that exposed U.S. government data-collection programs and Apple battled with federal investigators who sought data from the iPhone of a gunman who killed 14 in a San Bernardino, Calif., massacre. Apple declined to allow the government a method to bypass the phone's passcode, although the issue cooled when the Federal Bureau of Investigation found a third-party tool to hack the phone.

In public, Mr. Cook emphasized that Apple's business wasn't based on collecting user information, urging users to "follow the money" to see whether companies are profiting from gathering personal data.

Such comments rankled Mr. Zuckerberg and other Facebook executives, who bristled at the notion that advertising was out of step with customers and publicly questioned what they deemed the high prices of Apple's products, people who worked with them said. Some Facebook employees considered it hypocritical of Apple to embrace a public image of privacy consciousness when it did extensive business in China, some of the people said.

Facebook executives were unhappy with the pace at which Apple approved its app updates. Mr. Zuckerberg grumbled that Mr. Cook might be personally intervening to slow things down, according to people familiar with the discussions.

At various times, Mr. Zuckerberg proposed to his deputies, sometimes by email, that Facebook should delay launching new products on Apple devices and instead give the rival Android operating system an exclusive window, according to people familiar with the matter. Facebook didn't do so.

(MORE TO FOLLOW) Dow Jones Newswires

02-13-21 0014ET