Microsoft has won a major legal victory in the US, when a federal appeals court ruled that the government cannot force tech companies to hand over customers' emails that are stored in other countries.

A three-judge panel at the 2nd US Circuit Court of Appeals in Manhattan overturned a lower court decision, which ordered Microsoft to hand over a user's email account stored on its servers in Ireland. 

The US Department of Justice (DOJ) wanted to access data stored on the company’s servers in Dublin, Ireland, as part of a probe into a drugs case.

The software giant declined to release the data because the data was stored on servers physically situated outside of the US.

Circuit Court Judge Sarah Carney said: “We think Microsoft has the better of the argument.

“When, in 1986, Congress passed the Stored Communications Act as part of the broader Electronic Communications Privacy Act, its aim was to protect user privacy in the context of new technology that required a user’s interaction with a service provider.”

The DOJ said it was disappointed by the latest decision and is considering its future options. If the ruling is appealed, the case could now be moved to the US Supreme Court.

Microsoft president and chief legal officer Brad Smith said: “We obviously welcome today’s decision by the United States Court of Appeals for the Second Circuit.

“The decision is important for three reasons: it ensures that people’s privacy rights are protected by the laws of their own countries; it helps ensure that the legal protections of the physical world apply in the digital domain; and it paves the way for better solutions to address both privacy and law enforcement needs.”