Apple must provide "reasonable technical assistance" to investigators seeking to unlock the data on an iPhone 5C that had been owned by Syed Rizwan Farook, Judge Sheri Pym of U.S. District Court in Los Angeles said in a ruling.
That assistance includes disabling the phones auto-erase function, which activates after 10 consecutive unsuccessful passcode attempts and assisting investigators to submit passcode guesses electronically.
Apple did not immediately respond to a request for comment. The company has five business days to contest the order if it believes compliance would be "unreasonably burdensome," Pym said.
Federal prosecutors in Los Angeles on Tuesday requested the court order to compel Apple to assist the investigation into the Dec. 2 shooting rampage by Farook and his wife that killed 14 people and injured 22 others. The two were killed in a shootout with police.
The FBI has been investigating the couples potential
communications with the Islamic State and other militant groups and treating the case as an incident of domestic terrorism.
"Apple has the exclusive technical means which would assist the government in completing its search, but has declined to provide that assistance voluntarily," prosecutors said.
U.S. government officials have warned that the expanded use of strong encryption is hindering national security and criminal investigations.
Technology experts and privacy advocates counter that forcing U.S. companies to weaken their encryption would make private data vulnerable to hackers, undermine the security of the Internet and give a competitive advantage to companies in other countries.
In a similar case last year, Apple told a federal judge in New York that it was "impossible" for the company to unlock its devices that run an operating system of iOS 8 or higher.
The phone belonging to the Farook ran on iOS 9, according to prosecutors.
Prosecutors said Apple could still help investigators by disabling "non-encrypted barriers that Apple has coded into its operating system."
Apple and Google both adopted strong default encryption in late 2014, amid growing digital privacy concerns spurred in part by the leaks from former National Security Agency contractor Edward Snowden.
Forensics expert Jonathan Zdziarski said Tuesday Apple might
have to write custom code to comply with the order, presenting a novel question to the court about whether the government could order a private company to hack its own device.
Zdziarski said that because the San Bernardino shooting was being investigated as a terrorism case, investigators would be able to work with the NSA and CIA on cracking the phone. Those U.S. intelligence agencies likely could break the iPhones encryption without Apples involvement, he said.