Apple’s showdown with the FBI over an alleged San Bernardino terrorist’s iPhone has drawn heavy scrutiny lately, but the company has also been involved in a similar and ongoing legal battle over a different iPhone in law enforcement’s custody in New York. On Monday, Judge James Orenstein ruled in favor of Apple.

While the case is distinct from the San Bernardino case, there are parallels. In the NY case, the government demanded that Apple disable the security lock on an iPhone 5s running iOS 7. In that case, as in San Bernardino, the government argued that the All Writs Act of 1789, a law that’s as broadly open to interpretation as its age might suggest, granted it the authority to make such a request.

Judge Orenstein, in this ruling, disagrees. Of the All Writs application, he writes that “the government posits a reading…so expansive—and in particular, in such tension with the doctrine of separation of powers—as to cast doubt on the AWA’s constitutionality if adopted.”

Noting that Apple has been ordered under the authority of the All Writs Act to bypass the security of not one but 12 total devices, Orenstein rejects the argument that the All Writs act can be used as a “gap filler” that allows law enforcement to plug in powers that Congress has not yet granted or explicitly denied.

“In particular, unlike the government, Apple contends that a court order that accomplishes something Congress has considered but declined to adopt—albeit without explicitly or implicitly prohibiting it—is not agreeable to the usages and principles of law,” writes Orenstein, in reference to Apple’s argument that the Obama administration and Congress had previously passed on the opportunity to create laws around encryption. It’s also another nudge to Congress that it may be time for those laws to exist.

Importantly, Orenstein also draws a distinction between the case before him and a 1977 case involving New York Telephone under which the All Writs Act applied. That case, which first established that the AWA could be used to compel private companies to assist law enforcement, does not have much bearing here, according to the Orenstein ruling. Unlike New York Telephone, Orenstein notes, Apple is not a public company. It would do harm to its brand and its products if it complied with the order. And, importantly, it would be writing software outside of its normal line of business, whereas New York Telephone installed a device, known as a pen register, that it both already possessed and would feasibly install under the normal course of business.

Orenstein is similarly dismissive of the government’s other claims. “The government essentially argues that having reaped the benefits of being an American company, it cannot claim to be burdened by being seen to assist the government,” he writes. “Such argument reflects poorly on a government that exists in part to safeguard the freedom of its citizens… 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.”

That Orenstein ruled in favor of Apple is not surprising; the judge had indicated in October that he would not eagerly take the side of law enforcement. But the final result turns out to be a powerful refutation of arguments very similar to those on which the government has staked its case in San Bernardino. It's also notable that the San Bernardino case demands that Apple create a whole new operating system, which is an even greater demand for Apple than what law enforcement is pushing for in this NY case.

"If the California court has the same interpretation, then [Apple] will not be forced to aid in unlocking the iPhone," says Greg Boyd, an attorney who specializes in privacy and data security. "Among other pillars in the opinion, Judge Orenstein relies on Congress’s writing of the CALEA statute that explicitly forbids the type of interference requested in this and the California case. This case is also a reminder that the pending California case is not just about the phone in San Bernardino, but is in fact about accessing phones, whenever it is in the government’s interest to do so."

It’s hard to imagine a bigger win for Apple, or a more clear playbook for how the company will continue to fight its legal battles going forward. Whether San Bernardino takes this as precedent remains to be seen.