Mr Cook asserted such a move would undermine encryption by creating a back door that could potentially be used on other future devices.
His response, posted on the company’s website, came after an order from US magistrate judge Sheri Pym that Apple help the Obama administration break into an encrypted iPhone belonging to one of the shooters in the December attack.
The first-of-its-kind ruling was a significant victory for the US justice department in a technology policy debate that pits digital privacy against national security interests.
Noting the order from federal magistrate judge Sheri Pym in California, Mr Cook said “this moment calls for public discussion and we want our customers and people around the country to understand what is at stake”.
Mr Cook argued the order “has implications far beyond the legal case at hand”.
Judge Pym ordered Apple to help the FBI hack into an encrypted iPhone belonging to one of the San Bernardino shooters, setting the stage for a legal fight between the federal government and Silicon Valley over the ruling.
Mr Cook said the US government order would undermine encryption by using specialised software to create an essential backdoor that he compared to a “master key, capable of opening hundreds of millions of locks”.
“In the wrong hands, this software — which does not exist today — would have the potential to unlock any iPhone in someone’s physical possession,” Mr Cook wrote.
“The FBI may use different words to describe this tool, but make no mistake, building a version of iOS that bypasses security in this way would undeniably create a back door. While the government may argue that its use would be limited to this case, there is no way to guarantee such control.”
FBI director James Comey told members of Congress last week that encryption is a major problem for law enforcement who “find a device that can’t be opened even when a judge says there’s probable cause to open it”.
The ruling tied the problem to the deadliest terrorist attack on US soil since the 2001 attacks.
Syed Farook and his wife Tashfeen Malik killed 14 people in a December 2 shooting at a luncheon for Farook’s co-workers. The couple later died in a gun battle with police.
Federal prosecutors told the judge in Tuesday’s court proceeding — that was conducted without Apple being allowed to participate — that investigators cannot access a work phone used by Farook because they do not know his passcode and Apple has not co-operated.
The ruling requires Apple to supply highly specialised software the FBI can load on to the county-owned work iPhone to bypass a self-destruct feature, which erases the phone’s data after too many unsuccessful attempts to unlock it.