The iPhone belonged to one of the attackers in the San Bernardino shooting that killed 14 people.
US Magistrate Judge Sheri Pym ordered Apple to provide "reasonable technical assistance" to the FBI, including by disabling an auto-erase feature after too many unsuccessful attempts are made to unlock the iPhone 5C.
Female suspect of California shooting was Pakistani: CAIR
Federal prosecutors had filed a motion requesting Apple's help after the FBI failed to crack the phone's code.
By disabling the security features, the FBI will now be able to attempt as many different password combinations as needed before gaining access.
The phone was the property of the San Bernardino County Department of Public Health, which employed one of the shooters, Syed Farook.
California shooting suspect identified as Syed Farook: media
The county agreed to the search of the phone.
Farook, a US citizen, and his Pakistani wife Tashfeen Malik stormed a holiday work party in December and shot up their victims.
Pym, the judge, ordered that Apple provide software that would only run on the device in question, or any other technological means to access its data.
Who do we blame for Tashfeen Malik’s radicalisation?
The technology giant now has five days to comply with the order or seek relief if it determines that complying would be "unreasonably burdensome," Pym said.
"We have made a solemn commitment to the victims and their families that we will leave no stone unturned as we gather as much information and evidence as possible," US Attorney Eileen Decker said in a statement.
"The application filed today in federal court is another step -- a potentially important step -- in the process of learning everything we possibly can about the attack in San Bernardino."
FBI Director James Comey revealed last week that investigators had not been able to crack open the phone two months into the investigation.
'We feel ashamed': Pakistani relatives of California shooter
"It affects our counterterrorism work," he said.
Comey stressed the US government's concerns that commercially-available encryption benefits criminals.
Tech companies, intent on securing the trust of consumers after government spying revelations made by Edward Snowden, have been reluctant to be seen as helping authorities spy on users.
COMMENTS (1)
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ