Despite the campaign, the White House showed no appetite for legislation. And Apple showed no signs of budging. In a few instances, the two sides appeared bound for a court fight, only to resolve it at the last moment. Last summer, Apple refused to give the Justice Department real-time access to iMessages — the company’s proprietary text messages — in a gun case. The matter nearly escalated, but Apple eventually turned over some messages that had been backed up to the company’s iCloud servers. It was not all that the government wanted, but authorities viewed it as a sign of cooperation.

Such compromises forestalled a major court showdown, but increased the frustration at the Justice Department. Several current and former career prosecutors involved in the issue said they viewed it as hypocritical that Apple encouraged its customers to save its data to iCloud — which it would turn over to the government — but regarded the cellphone as sacrosanct.

Then came the Feng case. By refusing to help, the Justice Department thought Apple was sending a clear signal. If it would no longer cooperate with requests to help unlock old phones, there was little chance it would give in and build a way to unlock the new encrypted phones running iOS 8.

“Forcing Apple to extract data in this case, absent clear legal authority to do so, could threaten the trust between Apple and its customers and substantially tarnish the Apple brand,” Mr. Zwillinger said.

By that time, 90 percent of Apple devices were running iOS 8 or newer versions. The F.B.I. warned that it was only a matter of time before its agents were locked out of a phone in a case with lives at stake.

The San Bernardino attacks, which killed 14 people, presented the F.B.I. with a seemingly perfect test case. One of the shooters, Syed Rizwan Farook, was killed by the police and left behind a locked, encrypted iPhone 5c. The F.B.I. has not been able to unlock it.

Image Encrypted smartphones that are being held as evidence by the New York City Police Department were on display at the news conference. Credit... Bryan R. Smith for The New York Times

Mr. Farook’s phone is protected by a password that Apple says it does not keep and Apple says it cannot break the encryption without the password. The F.B.I. wants to write a program to send the phone an unlimited combination of passwords until it finds one that works.