Microsoft's latest attempt to resist a US government warrant demanding access to emails stored on servers in Ireland has been dismissed by a federal judge.
A court in New York ruled against the tech company, which has consistently fought the order issued in December as part of a drug-trafficking trial.
Microsoft immediately announced plans to challenge the decision.
The company has previously said it will allow users to choose where their data is stored.
Twitter released a report this week showing that the number of government requests for its users' data had almost doubled since last year.
The social network said it received 1,257 requests from the US authorities in the six months to the end of June, and it handed over some information in 72 percent of cases.
Microsoft's case has been closely watched by tech companies around the world, many of whom have rallied around their commercial rival's cause.
The legal battle, thought to be the only one of its kind in the US, could affect the wider tech industry, which faces mounting pressure from government authorities to allow access to data.
Last month, the UK voted through emergency legislation giving the security services access to people's phone and internet records, including some powers to go after those outside the country.
Microsoft, which is one of the world's largest email providers, says this case is about protecting data customers' rights to privacy.
The data requested by the US government is stored on servers in Dublin, the Irish capital, outside the country's legal jurisdiction.
Reacting to the New York judge's verdict, Microsoft said: "The district court's decision would not represent the final step in this process.
Brad Smith, the company's general counsel, said: "We will appeal promptly and continue to advocate that people's email deserves strong privacy protection in the US and around the world."