Apple has struck back in court against a US government demand that it unlock an encrypted iPhone belonging to one of the San Bernardino shooters, arguing such a move would violate its free speech rights and override the will of Congress.

The high-stakes fight between Apple and the government burst into the open last week when the FBI obtained a court order requiring Apple to write new software and take other measures to disable passcode protection and allow access to shooter Rizwan Farook's iPhone.

The clash has driven to the heart of a long-running debate over how much law enforcement and intelligence officials should be able to monitor digital communications.

Arguing that the court should throw out the order that it issued last week, Apple said in its brief on Thursday that software was a form of protected speech, and thus the Justice Department's demand violated the constitution.