"The United States government has demanded that Apple take an unprecedented step which threatens the security of our customers. We oppose this order, which has implications far beyond the legal case at hand," said Cook in an open letter.
The courts yesterday ruled that Apple should help the FBI unlock the phone to give access to data of Syed Rizwan Farook, one of the gunman who killed 14 people and injured 22 in a mass shooting in San Bernadino, California last year. The authorities are investigating the shooting as an act of domestic terrorism.
iPhones have a security feature which deletes all data if attempts to unlock the phone are not successful.
The ability to circumvent this security via a so-called backdoor, puts customers at risk and would damage their trust in the company, said Cook.
"For many years, we have used encryption to protect our customers’ personal data because we believe it’s the only way to keep their information safe. We have even put that data out of our own reach, because we believe the contents of your iPhone are none of our business," said Cook.
"When the FBI has requested data that’s in our possession, we have provided it. Apple complies with valid subpoenas and search warrants, as we have in the San Bernardino case. We have also made Apple engineers available to advise the FBI, and we’ve offered our best ideas on a number of investigative options at their disposal.
We have great respect for the professionals at the FBI, and we believe their intentions are good. Up to this point, we have done everything that is both within our power and within the law to help them. But now the US government has asked us for something we simply do not have, and something we consider too dangerous to create. They have asked us to build a backdoor to the iPhone."
Apple said there is no precedent for the request and that a backdoor will weaken encryption and security and that the move is an "overreach" of the government.
"Rather than asking for legislative action through Congress, the FBI is proposing an unprecedented use of the All Writs Act of 1789 to justify an expansion of its authority.
The government would have us remove security features and add new capabilities to the operating system, allowing a passcode to be input electronically. This would make it easier to unlock an iPhone by 'brute force,' trying thousands or millions of combinations with the speed of a modern computer.
The implications of the government’s demands are chilling. If the government can use the All Writs Act to make it easier to unlock your iPhone, it would have the power to reach into anyone’s device to capture their data. The government could extend this breach of privacy and demand that Apple build surveillance software to intercept your messages, access your health records or financial data, track your location, or even access your phone’s microphone or camera without your knowledge.
Opposing this order is not something we take lightly. We feel we must speak up in the face of what we see as an overreach by the US government."
Apple and other technology firms have previously spoken out against backdoor access for security agencies.
In response to the UK's Draft Investigatory Powers Bill, or "snooper's charter" which would let spy agencies have greater access to monitoring online communications, they rejected attempts to weaken encryption.