SAN FRANCISCO — It took six years for Apple to persuade China’s largest wireless carrier, China Mobile, to sell the iPhone. Apple’s chief executive, Timothy D. Cook, made repeated trips to China to meet with top government officials and executives to woo them personally.
The persistence paid off. In 2013, China Mobile relented, a moment Mr. Cook later described as “a watershed day” for Apple.
Today, China is Apple’s second-largest market after the United States — Chinese consumers spent $59 billion on Apple products in the last fiscal year — and the iPhone, the company’s top seller, has become both a status symbol and a form of personal security, given how difficult the device is to break into in a country where people increasingly worry about hacking and cybercrime.
Apple’s success in China helps explain why it is now in a standoff with the United States government over whether to help officials gain access to the encrypted iPhone of one of the attackers in the San Bernardino, Calif., mass shooting last December.
The company is playing the long game with its business. Privacy and security have become part of its brand, especially internationally, where it reaps almost two-thirds of its almost $234 billion a year in sales. And if it cooperates with one government, the thinking goes, it will have to cooperate with all of them.
“Tim Cook is leveraging his personal brand and Apple’s to stand on the side of consumer privacy in this environment,” said Mark Bartholomew, a law professor at the University at Buffalo who studies encryption and cyberlaw. “He is taking the long view.”
Mr. Cook, who has called privacy a civic duty, said as much in a letter to Apple customers on Tuesday. He described how the United States government was asking for a special tool to break into the San Bernardino attacker’s iPhone and said, “The government suggests this tool could only be used once, on one phone. But that’s simply not true. Once created, the technique could be used over and over again, on any number of devices.”
An Apple spokeswoman declined to comment beyond the remarks in Mr. Cook’s letter.
The business advantage Apple may get from privacy has given critics an opening to attack the company. In a court filing on Friday, the Justice Department said Apple’s opposition to helping law enforcement appeared “to be based on its concern for its business model and public brand marketing strategy.”
Apple senior executives responded that their defiance was not a business choice. They added that there had not been any business fallout and that Mr. Cook had received supportive emails from customers across the country.
In fact, Apple has not made a point of advertising data security and privacy. The company has quietly built privacy features into its mobile operating system, known as iOS, over time. By late 2013, when Apple released its iOS 7 system, the company was encrypting by default all third-party data stored on customers’ phones. And iOS8, which became available in 2014, made it basically impossible for the company’s engineers to extract any data from mobile phones and tablets.
Mr. Cook has also been vocal about how Apple is pro-privacy, a message that he discussed more widely after revelations from the former intelligence contractor Edward J. Snowden about government surveillance. Mr. Cook argued that the company sold hardware — phones, tablets and laptops — and did not depend on the mass collection of consumer data as some Silicon Valley behemoths, such as Google and Facebook, do for their advertising-oriented businesses.
At a conference in October, Mr. Cook called privacy a “key value” at Apple and said, “We think that it will become increasingly important to more and more people over time as they realize that intimate parts of their lives are sort of in the open and being used for all sorts of things.”
For Apple, cooperating with the United States government now could quickly lead to murkier situations internationally.
In China, for example, Apple — like any other foreign company selling smartphones — hands over devices for import checks by Chinese regulators. Apple also maintains server computers in China, but Apple has previously said that Beijing cannot view the data and that the keys to the servers are not stored in China. In practice and according to Chinese law, Beijing typically has access to any data stored in China.
If Apple accedes to American law enforcement demands for opening the iPhone in the San Bernardino case and Beijing asks for a similar tool, it is unlikely Apple would be able to control China’s use of it. Yet if Apple were to refuse Beijing, it would potentially face a battery of penalties.
Analysts said Chinese officials were pushing for greater control over the encryption and security of computers and phones sold in the country, though Beijing last year backed off on some proposals that would have required foreign companies to provide encryption keys for devices sold in the country after facing pressure from foreign trade groups.
“People tend to forget the global impact of this,” said Raman Jit Singh Chima, policy director at Access Now, a nonprofit that works for Internet freedoms. “The reality is the damage done when a democratic government does something like this is massive. It’s even more negative in places where there are fewer freedoms.”
Governments in Russia, Britain and Israel also have robust surveillance operations. Some governments have tried to use technology to gather intelligence on citizens at home and abroad.
Apple’s resistance to the United States government’s demand has been polarizing. Apple supporters have held protests in cities like San Francisco in recent days to show their support of the company and have used hashtags on social media like #freeapple and #beatthecase.
“We’re fighting to maintain even the assumption that companies should protect us,” said Evan Greer, the campaign director at Fight for the Future, a civil liberties group that is organizing protests nationwide on Tuesday to support Apple. “Apple is doing what every company should be doing.”
Others, including the Republican presidential candidate Donald J. Trump, have criticized Apple, and Mr. Trump has suggested boycotting its products.
Around the world, people are aware of the impasse but many say it does not affect their decision to buy iPhones and the company’s other products. In Rome on Friday, Simone Farelli, a 34-year-old history teacher who was browsing for a new iPhone at an Apple Store, said she “didn’t see why” the company’s standoff with the Federal Bureau of Investigation “would change my mind about buying a new phone.”
In China, the iPhone continues to hold a special place as a symbol of middle-class status.
Wen Shuyue, a 35-year-old consultant, who on Friday was waiting outside the Apple Store in Beijing’s upscale Sanlitun district, is one of Apple’s millions of Chinese users. He said he liked the iPhone because it was simply better than models made by Chinese companies such as Xiaomi and Huawei.
“I’ve never used Xiaomi or Huawei, because I think their designs are rough and not all that personal,” he said.
Apple’s shareholders have so far been quiet. In the past, investors who complained that some of Apple’s socially driven initiatives were superfluous to the company’s core business were quickly subdued. At a 2014 shareholders’ meeting, Mr. Cook told investors that if they wanted him to make decisions based only on the bottom line, “then you should get out of the stock.”
But data privacy may eventually motivate investors — and ultimately more customers — to vote with their wallets because “it’s an issue that speaks directly to the business,” said Michael Cusumano, a professor at the M.I.T. Sloan School of Management. “Right now people buy phones regardless of encryption issues, but we have to wait and see how bloody this fight gets.”