Apple Chief Executive Tim Cook said his company opposed a demand from a U.S. judge to help the FBI break into an iPhone recovered from one of the San Bernardino shooters.

Cook said that the demand threatened the security of Apple's customers and had "implications far beyond the legal case at hand."

RELATED: Could this signal the decline of iPhone sales?

Judge Sheri Pym of the U.S. District Court in Los Angeles said on Tuesday that Apple must provide "reasonable technical assistance" to investigators seeking to unlock data on an iPhone 5C that had been owned by Syed Rizwan Farook.

In a letter to Apple's customers, Cook said the FBI had asked the company to build "a backdoor to the iPhone."

"The government is asking Apple to hack our own users and undermine decades of security advancements that protect our customers — including tens of millions of American citizens — from sophisticated hackers and cybercriminals," he said.

RELATED: Hidden iPhone feature tracks your every move – here’s how to access it

"We can find no precedent for an American company being forced to expose its customers to a greater risk of attack."