Apple scored a major legal victory in its ongoing battle against the FBI on Monday when a federal magistrate judge in New York rejected the U.S. government’s request as part of a drug case to force the company to help it extract data from¬†a¬†locked¬†iPhone. The ruling¬†from U.S. Magistrate Judge James Orenstein was issued as part of the criminal case against¬†Jun Feng, who pleaded guilty in October to drug charges. It is a significant¬†boost to Apple’s well-publicized campaign¬†to resist the FBI’s similar efforts in the case of the San Bernardino killers.

In the case that gave rise to Monday’s ruling, the Drug Enforcement Administration¬†had seized — but, even after consultation with the FBI, claimed it was unable to access — Feng’s¬†iPhone 5. The DEA and FBI said they could not overcome security measures embedded in Apple’s operating system. The government thus filed a motion seeking an order requiring “Apple to assist” the investigation¬†“under the authority of the All Writs Act” — the same 1789 law the FBI is invoking in the San Bernardino case — by “help[ing] the government bypass the passcode security.” Apple objected, noting that there were nine other cases currently pending¬†in which the government was seeking a similar order.

Judge Orenstein applied previous legal decisions¬†interpreting the AWA and concluded that the¬†law does not “justif[y] imposing on Apple the obligation to assist the government’s investigation against its will.” In a formulation¬†extremely favorable to Apple, the judge wrote that the key question raised by the government’s request is whether the AWA allows a court “to compel Apple — a private party with no alleged¬†involvement in Feng’s criminal activity — to perform work for the government against its will.”

The court ruled that the law permits no such result — both because relevant law contains limits on what companies like Apple are required to do, and because Congress never enacted any such obligations. Moreover, the judge said of the government’s arguments for how the AWA¬†should be applied: “The implications of the government’s position are so far-reaching — both in terms of¬†what it would allow today and what it implies about congressional intent in 1789 — as to produce¬†impermissibly absurd results.”

Perhaps most devastating to the FBI’s case is Orenstein’s recognition that the purpose of the¬†FBI’s request¬†is not simply to obtain evidence in one particular case, but rather to grant the government broad, precedential authority to force Apple and other tech companies to take affirmative technological steps to cooperate with criminal investigations¬†generally. That the FBI is seeking to establish broad precedent is a key argument made by Apple and its supporters in the San Bernardino case. To accept that the U.S. government has this power, ruled the court, is to vest law enforcement agencies with statutory authority that Congress itself never enacted:

The¬†Application before this court is by no means singular: the government has to date successfully invoked¬†the AWA to secure Apple’s compelled assistance in bypassing the passcode security of Apple devices¬†at least 70 times in the past; it has pending litigation in a dozen more cases in which Apple¬†has not yet been forced to provide such assistance; and in its most recent use of the statute it goes so¬†far as to contend that a court — without any legislative authority other than the AWA — can require¬†Apple to create a brand new product that impairs the utility of the products it is in the business of¬†selling.

It is thus clear that the government is relying on the AWA as a source of authority that is legislative in every meaningful way: something that can be cited as a basis for getting the relief it seeks in case after case without any need for adjudication of the particular circumstances of an individual case (as the arguments that the government relies on here to justify entering an AWA order against Apple would apply with equal force to any instance in which it cannot bypass the passcode security of an Apple device it has a warrant to search).

The judge also accused the government of trying to manipulate secret judicial proceedings to obtain powers for itself against Apple that public debate and Congress would never permit. It is, Orenstein wrote, “clear that¬†the government has made the considered decision that it is better off¬†securing such crypto-legislative authority from the courts (in proceedings that had always been, at the¬†time it filed the instant Application, shielded from public scrutiny) rather than taking the chance that¬†open legislative debate might produce a result less to its liking.”¬†Because the government wants the courts rather than Congress to grant this power,¬†the “government’s interpretation of the breadth of authority the AWA confers on courts of¬†limited jurisdiction … raises serious doubts about how such a statute could withstand constitutional¬†scrutiny under the separation-of-powers doctrine.”

Monday’s ruling boosts Apple’s case against the FBI in numerous other ways, as much of it is applicable to the San Bernardino case. To begin with, the judge emphasized that “Apple had no involvement in Feng’s crime, and it has taken no affirmative¬†action to thwart the government’s investigation of that crime” — exactly as is true for San Bernardino. Moreover, “Apple lawfully sold to Feng, as it sells to millions of law-abiding individuals and entities¬†(including the government itself), a product that can effectively secure its stored data for the protection¬†of its owner,” and “Feng used that device for criminal purposes and left it locked” — as is also true for San Bernardino.

Crucially, the ruling emphasized that “Apple is not ‘thwarting’ anything — it is instead merely declining to offer assistance.” While a party may — or may not — have a moral duty to assist the government in criminal investigations, “nothing in¬†[prior case law]¬†suggests that the ‘duty’ … is legal rather than moral.” Particularly since Congress has explicitly authorized companies to produce telecommunications devices with security measures, there is no basis to conclude that Apple has done anything wrong by enabling its customers to lock their devices.

Finally, the ruling recognized that forcing Apple to compromise its own security systems at the behest of the U.S. government would impose a considerable cost far beyond financial expenses:

In considering the burden the requested relief would impose on Apple, it is entirely appropriate to¬†take into account the extent to which the compromise of privacy and data security that Apple promises¬†its customers affects not only its financial bottom line, but also its decisions about the kind of¬†corporation it aspires to be. The fact that the government or a judge might disapprove Apple’s¬†preference to safeguard data security and customer privacy over the stated needs of a law enforcement¬†agency is of no moment: in the absence of any other legal constraint, that choice is Apple’s to make,¬†and I must take into account the fact that an order compelling Apple to abandon that choice would¬†impose a cognizable burden on the corporation that is wholly distinct from any direct or indirect¬†financial cost of compliance.

This cost, Orenstein wrote, is¬†particularly high¬†since — rejecting the FBI’s claim¬†in the public debate that its request is limited to just one phone — “the record of this case makes clear that the burdens the government¬†seeks to impose on Apple under the authority of the AWA are not nearly so limited.” To the contrary, “it clearly intends to continue seeking assistance that is similarly¬†burdensome — if not far more so — for the foreseeable future.”

The judge seemed to find particularly offensive¬†the government’s claim that because Apple is a U.S. company and receives benefits from American society, it has a duty to assist the U.S. government:

Such argument reflects poorly on a government that exists in part to safeguard the freedom of¬†its citizens — acting as individuals or through the organizations they create — to make autonomous¬†choices about how best to balance societal and private interests in going about their lives and their¬†businesses. The same argument could be used to condemn with equal force any citizen’s chosen form¬†of dissent. All American citizens and companies “derive significant legal, infrastructural, and political¬†benefits from [their] status [as such]” — but that cannot mean that they are not burdened in a legally cognizable way when forced unwillingly to comply with what they sincerely believe to be an unlawful¬†government intrusion.

Throughout the opinion, one finds extreme skepticism about the government’s true intentions. In particular, Orenstein repeatedly noted that the government could not demonstrate, or even state, that it would be unable to access the iPhone without Apple’s help, strongly suggesting that its real objective is to vest itself with broad authority for future cases that Congress never decided it¬†should possess.

Apple, for its part, insisted on a conference call Monday that this ruling constituted a major victory. A senior Apple executive noted that the case “is the first opportunity that any court has had to consider … the demands of the All Writs Act on Apple … to facilitate the government’s access to an iPhone,” and that Orenstein “completely sides with Apple.” The Apple executive continued:¬†“The court found that Congress has made a legislative choice to exclude Apple from the assistance requirement”; if the government succeeded, it would be “giving the government power that Congress had considered and rejected.”

The ruling by no means guarantees Apple’s victory in the broader fight against the FBI or even in the San Bernardino case. Orenstein had previously issued rulings making clear that he sympathized with Apple’s position, rendering¬†the¬†ruling somewhat expected. Moreover, as a magistrate judge — the level lower than U.S. district judge — his rulings are binding on no other court. It could conceivably add fuel to the movement to have Congress enact a new statute vesting the FBI with these powers. And there are possible distinctions with the San Bernardino case the FBI could make, such as¬†its diminished ability to access a more advanced phone, as well as¬†the relative importance of that investigation (international terrorism v. drug charges).

On the other hand, because the device at issue in the San Bernardino case uses¬†a more advanced operating system than the one in the New York case, the demands the FBI is making of Apple in California are much greater. The Apple executive made the point this way today: “The difference is fundamental in terms of what we’re being asked to do ‚ÄĒ to create something that does not exist, which would defeat the protective mechanisms that we’ve built into our operating systems. That’s the issue in New York, but I think it’s incredibly important because in San Bernardino, the burden that the government is trying to impose on Apple is far more onerous.”

Though not binding, Monday’s ruling is almost certainly a major boost for Apple, both because of how categorical it¬†is in its rationale in Apple’s favor, and because it’s the first judicial decision to address these issues directly. In essence, a U.S. judge adopted virtually all of the key arguments Apple has been making against the FBI and, in doing so, ruled that the U.S. government lacks the authority it claims it has to force the company to assist it in criminal investigations by creating new software to help the government break through the company’s own security systems.

Read the ruling: