NEW YORK - A federal appeals court on Thursday said Microsoft Corp and other companies cannot be forced to turn over customer emails stored on servers outside the United States.

The 3-0 decision by a panel of the 2nd US Circuit Court of Appeals in New York was a victory for privacy advocates, as well as for technology companies hoping to offer cloud computing and other services to customers around the world.

Circuit Judge Susan Carney said communications held by US service providers on servers located outside the United States are beyond the reach of domestic search warrants issued under the Stored Communications Act, a 1986 federal law. “Congress did not intend the SCA’s warrant provisions to apply extraterritorially,” she wrote. “The focus of those provisions is protection of a user’s privacy interests.”

Microsoft had been challenging a warrant seeking emails stored on a server in Dublin, Ireland, in a narcotics case.

It was believed to be the first US company to challenge a domestic search warrant seeking data held outside the country. Thursday’s decision reversed a July 2014 ruling by then-Chief Judge Loretta Preska of the US District Court in Manhattan requiring Microsoft to turn over the emails. It also voided a contempt finding against the company.

The office of US Attorney Preet Bharara in Manhattan, which defended the warrant, declined to comment. Microsoft did not immediately respond to requests for comment. Microsoft’s case has attracted strong interest from the technology and media sectors. Dozens of companies, organizations and individuals filed briefs supporting the company’s appeal, including Inc , Apple Inc, Cisco Systems Inc, CNN , Fox News Network, Gannett Co and Verizon Communications Inc.

Microsoft had said the warrant could not reach emails on the Dublin server because US law did not apply there.

The Redmond, Washington-based company also said enforcing its warrant could spark a global “free-for-all,” where law enforcement authorities elsewhere might seize emails belonging to Americans and stored in the United States.

Federal prosecutors countered that quashing warrants such as Microsoft’s would impede their own law enforcement efforts.

But Judge Carney said limiting the reach of warrants serves “the interest of comity” that normally governs cross-border criminal investigations.

She said that comity is also reflected in treaties between the United States and all European Union countries, including Ireland, to assist each other in such probes.

Circuit Judge Gerard Lynch concurred in the judgment, and urged Congress to update the “badly outdated” 1986 law to strike a better balance between current law enforcement needs and users’ privacy interests and expectations.

He said the law as it stands lets Microsoft thwart an otherwise justified demand to turn over emails by the “simple expedient” of choosing to store them outside the United States. “I concur in the result, but without any illusion that the result should even be regarded as a rational policy outcome, let alone celebrated as a milestone in protecting privacy,” he wrote.

The case is In re: Warrant to Search a Certain E-Mail Account Controlled and Maintained by Microsoft Corp, 2nd US Circuit Court of Appeals, No. 14-2985.