"Building a version of iOS that bypasses security in this way would undeniably create a backdoor," Cook wrote. "And while the government may argue that its use would be limited to this case, there is no way to guarantee such control."
Apple plans to file an opposition to the magistrate's ruling within the next four days, according to an executive familiar with the matter who spoke on condition of anonymity.
The court order marks the first time Apple has been asked to modify its software to access data sought by the government, the executive said.
On Tuesday, U.S. Magistrate Judge Sheri Pym in Riverside directed Apple to help the FBI get around the phone's passcode protection and the device's auto-erase function, which would permanently destroy any encrypted data on the phone after 10 unsuccessful login attempts.
In a motion filed earlier Tuesday, the FBI argued that Farook intentionally disabled the phone's iCloud backup function six weeks before the Dec. 2 terror attack at the Inland Regional Center. Any communications linked to the shooting, as well as location data that might help the FBI map the movements of Farook and his wife, Tashfeen Malik, after the attack are accessible only through the phone itself, the government argued.
Investigators want to unlock the phone by using a computer program to automatically guess numeric passcodes until one works, according to a court filing. But they say they require special access from Apple to attempt that on the phone without erasing data or getting bogged down in a long process.
In September 2014, Apple modified its encryption system in a move that made it more difficult for law enforcement to access data on its cellphones. Previously, forensic investigators could tap into a device's hardware port and gain access to a phone's data "independent of needing to try passcodes," according to Clifford Neuman, director of USC's Center for Computer System Security.
"That path into the device is no longer possible," he said.
Pym's order would require Apple to write a new software program, a "recovery bundle" that would reboot Farook's iPhone 5C with different settings, allowing the FBI to repeatedly enter passcodes remotely without risk of destroying the data on the phone. The program also would allow agents to attempt to enter passcodes without incurring a delay between each incorrect attempt.
Robert Cattanach, a cybersecurity attorney and former Department of Justice special counsel to the secretary of the Navy, said the government's request leaves Apple in a difficult position as the company is now thrust into the center of the battle to balance privacy needs against counterterrorism efforts.
"The FBI's request to a U.S. Magistrate for an order requiring Apple to disable the auto-wipe feature after 10 unsuccessful attempts represents the next step in the journey to find the holy grail of back door unencryption, and the next salvo in the ever-escalating battle between law enforcement and tech companies," Cattanach said.
Gregory T. Nojeim, director of the Freedom, Security and Technology Project at the Center for Democracy & Technology, said the federal government is essentially trying to win access that it failed to gain through legislation in recent years.
"If this decision is upheld, it would mean the FBI could get a judicially mandated back door into any device to get access to its content, and it would mean a weakening of encryption in all those devices," he said.
That back door potentially could be used on other devices too, making it a "bigger deal" beyond the terrorist case, according to Nojeim, who said tech companies likely will rally around Apple.
"I suspect that the entire technology industry, security professionals and technologists will all line up against this and urge the court to reject it," he said. "The consensus of the technical community of backdooring encryption is phenomenal."
Chenxi Wang, chief strategy officer at the network security firm Twistlock, said the court battle will be a seminal moment in balancing "privacy and civil liberty against government data access."
"If Apple succeeds in fighting the court order, it will set up a high barrier for the FBI and the other government groups to access citizen data from now on," Wang said. "This will absolutely have a ripple effect. Apple is now viewed as the flag bearer for protecting citizen data, and if they succeed, there will be a flood of other companies following suit."
Alex Abdo, a staff attorney for the American Civil Liberties Union, said the order "risks setting a dangerous precedent."
Civil liberties advocates fear that totalitarian governments such as China will demand Apple use a similar tool to open phones of opposition leaders and human rights activists.
"If the FBI can force Apple to hack into its customers' devices, then so too can every repressive regime in the rest of the world," Abdo said in a statement.
Apple's refusal to assist the FBI may increase calls for a federal law that requires tech companies to design products that law enforcement officials can access with a search warrant. Any push for legislation would face stiff resistance from privacy advocates and technology companies, who say they are building products with encryption to protect users' privacy and data from hackers, and because customers want it.
The Obama administration, which has increasingly reached out to Silicon Valley over the past year, has not asked Congress to intervene in the hope that technology company executives would find a way to comply with search warrants in terrorism and criminal cases while still protecting their customers' privacy.
While Apple's stance may, on its face, appear to be a defense of privacy and civil liberties, the company also could lose face in front of international customers if it cooperates with American law enforcement.
"We also should not forget that Apple derives a lot of its revenues from international sales, and Apple stands to lose much if they are viewed as a company that cooperates with the American government," Wang said. "They stand to lose a significant amount, particularly in places like China. So it's not a completely innocent thing they're doing."
In the government's motion, the FBI asked Apple to create a software package designed to function only on Farook's phone. But that may not be possible, experts said.
"The question then is whether Apple has the technology to allow the bypassing of the 10-tries-you're-out mechanism," Neuman said. "It's my guess that Apple did not specifically design the device to do that."
Other experts said the company is likely more concerned with the implications of creating software to defeat its own security measures than with the actual work required to do so.
"It's not the hardest thing in the world to deal with this issue," said Jan Dawson, chief analyst at Jackdaw Research, a technology advisory firm. "They're worried about setting the precedent, of saying, 'Apple devices are incredibly secure, unless we get a subpoena.' "
Apple has five days to appeal the judge's decision.
Presidential candidates began weighing in on the issue Wednesday morning. GOP front-runner Donald Trump said he was floored that Apple had not volunteered to aid the FBI.
"To think that Apple won't allow us to get into her cellphone — who do they think they are?" Trump told Fox News. "No, we have to open it up."
The phone was actually given to Farook by the San Bernardino County Department of Health, where he worked as an inspector. It did not belong to Malik, as Trump seemed to reference.
Speaking to reporters in South Carolina, Sen. Marco Rubio said he hoped the tech giant would voluntarily comply with the government's request, but acknowledged the court order is far from a simple issue.
"Look, I think this is a tough issue. There's no easy answers for the encryption issue. Because on the one hand, this encryption is designed to prevent people from having unauthorized access to your private information," he said. "On the other hand, there are terrorists and criminals who are using encryption to protect themselves. So I really think this is going to require us to work very closely with the technology industry to find a solution."
Lien reported from San Francisco. Bennett reported from Washington, D.C. Queally, Dave and Winton reported from Los Angeles. Times staff writers Seema Mehta in South Carolina and Joel Rubin in Los Angeles contributed to this report.