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.