Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

Apple is fiercely opposing a court order to unlock the iPhone used by one of the San Bernardino shooters, accusing the federal government of an “overreach” that could potentially breach the privacy of millions of customers.

CEO Tim Cook published a bullish open letter late Tuesday, pledging to fight a judge’s ruling that it should give FBI investigators access to encrypted data on the device.

“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,” Cook wrote, calling the ruling a “dangerous precedent.”

The U.S. Attorney's Office in Los Angeles argued the FBI needed Apple to help it find the password and access "relevant, critical … data" on the locked cellphone of Syed Farook, who with his wife Tashfeen Malik murdered 14 people in San Bernardino, California, on Dec. 2.

"It would be the equivalent of a master key, capable of opening hundreds of millions of locks"

Apple has five days to respond to the court if it believes that compliance would be burdensome.

“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 U.S. government,” Cook wrote in the open letter to customers.

Byers Market Newsletter Get breaking news and insider analysis on the rapidly changing world of media and technology right to your inbox. This site is protected by recaptcha

“We are challenging the FBI’s demands with the deepest respect for American democracy and a love of our country. We believe it would be in the best interest of everyone to step back and consider the implications.”

He said the request would ultimately “undermine the very freedoms and liberty our government is meant to protect.”

Alex Abdo, an American Civil Liberties Union staff attorney, called it an "unprecedented, unwise and unlawful move" by the government.

"The Constitution does not permit the government to force companies to hack into their customers' devices. Apple is free to offer a phone that stores information securely, and it must remain so if consumers are to retain any control over their private data," Abdo said.

"If the FBI can force Apple to hack into its customers' devices, then so too can every repressive regime in the rest of the world," he added. "Apple deserves praise for standing up for its right to offer secure devices to all of its customers.”

Prosecutors argued evidence in Farook's iCloud account indicates that he was in communication with victims whom he and his wife later shot, and phone records show Farook communicated with Malik using his iPhone.

They alleged in their filing that Farook may have disabled the iCloud data feature to hide evidence. Although investigators have been able to obtain several backup versions of Farook's iCloud data, the most recent version they've been able to access dates from about a month and a half before the shooting. They said this showed Farook "may have disabled the feature to hide evidence."

Tim Cook Carlo Allegri / Reuters

Cook insisted Apple had “worked hard to support the government’s efforts to solve this horrible crime,” but said the government had “asked us to build a backdoor to the iPhone” — something he described as “too dangerous to create.”

He said the suggestion that a tool to hack the iPhone could only be used once was “simply not true.”

“Once created, the technique could be used over and over again, on any number of devices,” Cook said. “In the physical world, it would be the equivalent of a master key, capable of opening hundreds of millions of locks — from restaurants and banks to stores and homes. No reasonable person would find that acceptable.”

He also suggested that the government could use the same legislation cited in Tuesday’s ruling to demand that tech companies build surveillance software to intercept customers’ messages.

“We can find no precedent for an American company being forced to expose its customers to a greater risk of attack,” he wrote. “The implications of the government’s demands are chilling. While we believe the FBI’s intentions are good, it would be wrong for the government to force us to build a backdoor into our products.”