Apple has asked a US court to overturn an earlier ruling ordering the company to help the FBI break into a phone used by one of the San Bernardino killers.
In court papers Apple says law enforcement authorities are seeking “dangerous powers” and the move violates its constitutional rights.
The FBI and White House have said the request is limited to one iPhone.
But Apple says the software needed to comply with the FBI’s request “simply does not exist”.
Instead Apple says it would have to create a new version on the iPhone operating software, containing a back door to the device’s encrypted data.
It argues that the lower court did not have the authority to force Apple to do that.
Apple also says no court had ever forced a company to weaken the security of its products to gain access to personal individual information.
“This case is about the Department of Justice and the FBI seeking through the courts a dangerous power that Congress and the American people have withheld,” the filing said.
Analysis – Dave Lee, BBC North America technology reporter
In appealing to the American public, there are numerous boxes you can tick to quickly gain support; strings that tug at the mind of almost every person living in this country.
In this case, the FBI went with fighting against terror, and the need to beat the so-called Islamic State. Few would disagree with that motive, and even Tim Cook has acknowledged the compelling moral argument for unlocking the phone.
But if there’s one things Americans worry about more than terrorists, it’s the erosion of their constitutional rights. In Apple’s court motion on Thursday, the company ticked the biggest box of all: freedom of speech.
The code it writes, the company argues, is the company’s speech, it’s expression.
Forcing it to write code and create a “GovtOS” – a play on iOS, the software that powers the iPhone – would be forcing Apple to write code it disagreed with, the company says.
It may be the argument that tips the balance in the court of public opinion.
Testifying before congress Mr Comey said: “This is the hardest question I have seen in government and it’s going to require negotiation and conversation.”
The row between Apple and the FBI blew up last week when the bureau asked the electronics firm for help to unlock the smartphone of Syed Rizwan Farook – who along with his wife killed 14 people in December 2015.
So far, Apple has refused to unlock the phone.
In an interview aired yesterday with US TV network ABC, Apple boss Tim Cook said the FBI was asking it to make “the software equivalent of cancer”.
He added: “Some things are hard and some things are right. And some things are both. This is one of those things.”
Apple has argued that the FBI’s request violates its constitutional right to freedom of speech, because a 1999 court case ruled that computer code is considered speech.
By forcing Apple to create a new code the FBI was violating a constitutional right, the company said.
Apple’s attorney, Bruce Sewell will testify before Congress on 1 March about the encryption case.
Tech leaders, including Google’s boss, and Apple customers have praised the company for standing up to the FBI.
Apple supporters rallied in front of the company’s stores on Tuesday to show their support.
A Department of Justice court filing from February accused Apple of refusing to help to boost its “marketing strategy”.