A US magistrate has ordered Apple to help the FBI get access to the phone of one of the San Bernardino shooters.

(Image: file photo)

Judge Sheri Pym ruled Tuesday that the iPhone and iPad maker must provide a tool that would allow federal agents to beat a security feature preventing the phone from erasing after a number of failed unlocking attempts, according to the AP.

The court ruling did not order Apple to break the encryption, but said it should offer "reasonable technical assistance" to law enforcement.

Prosecutors said they can't access the iPhone 5c used by Syed Farook, because they don't know the passcode.

"Apple has the exclusive technical means which would assist the government in completing its search, but has declined to provide that assistance voluntarily," the prosecutors said.

Apple began encrypting its iPhones and iPads with a passcode in iOS 8, released in September 2014, thought to be partly in response to claims of collusion in mass surveillance by government agencies.

The move prevents law enforcement from compelling Apple to unlock devices running newer versions of the software -- about 94 percent of devices.

Later versions of Apple's mobile software increased the passcode from four-digits to six-digits, making brute-force attacks designed to bypass the passcode more difficult to accomplish.

Farook and his wife, Tashfeen Malik, murdered 14 people in San Bernardino, California in December 2015.

The FBI later said it was treating the mass shooting as a terrorist attack.

The court order comes just a week after FBI director James Comey, who has advocated for backdoors in encryption to help investigations, said the agency was "still working" on gaining access to the gunman's phone.

Apple CEO Tim Cook says the company will fight a court order.