A federal judge in New York has ruled that Apple cannot be forced to provide US authorities with access to a locked iPhone, which could have major implications for a well-publicised battle between the two parties.

The US Justice Department had requested that Apple unlock a phone as part of a drug case, but Judge Orenstein in Brooklyn denied the motion.

A 1789 law called the All Writs Act had been cited in both cases, which allows US federal courts to "issue all writs necessary or appropriate in aid of their respective jurisdictions and agreeable to the usages and principles of law."

However, Orenstein argued that the act could not be applied in this case and that Apple was exempt through a 1994 law on wiretapping.

Yesterday’s ruling will be encouraging for Apple, which is currently facing the FBI in court in San Bernandino over demands to unlock the iPhone of Syed Rizwan Farook, a suspected terrorist.

The FBI has demanded that Apple create a new version of the iOS with less security and install it on Farook’s iPhone, which was recovered in the investigation into his crimes.

In a letter to customers, Apple CEO Tim Cook said that the FBI’s demands that they build a new version of the software would create a "backdoor" and open up data to criminals and hackers.

"In the wrong hands, this software — which does not exist today — would have the potential to unlock any iPhone in someone’s physical possession," Cook wrote.

The same All Writs Act is being cited in the San Bernandino case, meaning that the judge there may examine this ruling closely. Cook said that this created a "dangerous precedent".

"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."