WASHINGTON — The U.S. Supreme Court on Tuesday takes up a battle between the federal government and the internet giant Microsoft over the privacy of its customers' data.

The issue is straightforward: Can the company be compelled to turn over emails stored on overseas servers?

A victory for the government, privacy advocates say, would set off a global free-for-all, with nothing to stop any country from seeking data stored anywhere in the world.

But the Justice Department says a win for Microsoft could create data havens, places where governments would be unable to obtain evidence of serious crimes.

The dispute began in 2013, when federal agents served a search warrant on Microsoft's headquarters in Redmond, Washington, seeking the contents of an MSN.com account they claimed was being used to conduct drug trafficking.

Microsoft said it couldn't comply, because the emails were stored on the company's servers in Dublin — one of the company's more than 100 data centers in 40 countries. Search warrants issued in the U.S., it said, have no effect beyond U.S. borders.

In essence, the company told the federal agents to go ask Ireland for the data.

A key issue in the case is where the search occurs.

The Justice Department argues that Microsoft can easily call up the data with a few keystrokes at its headquarters. That means the search takes place where the company hands the data over, the government says, not where it transfers emails internally from one data center to another.

"Any invasion of privacy occurs only when Microsoft divulges a user's communications to the government and the government examines those communications for evidence of a crime," Solicitor General Noel Francisco wrote in his Supreme Court brief. He said the search warrant gives the government authority to see those emails.

If the law didn't work that way, Francisco added, internet companies "could move all information about U.S. subscribers beyond the reach of U.S. law enforcement simply by building its servers outside the United States."

But Microsoft says the search happens where the data is stored, not where a computer operator happens to sit. The company can no more be compelled to produce the evidence stored overseas than Hilton could be required to send a housekeeper to a hotel room in Dublin, photograph a guest's papers and email copies to Washington.

It doesn't matter, the company said, that its employees are performing the actual data retrieval, because they're acting under court orders, which makes the search a government one, not a private act.

"We believe that people's privacy rights should be protected by the laws of their own countries, and we believe that information stored in the cloud should have the same protections as paper stored in your desk," said Brad Smith, Microsoft's chief legal officer.

Privacy groups are lined up on Microsoft's side. If the Supreme Court rules for the government, "any country could seek data stored anywhere in the world, including the United States, based only on that nation's own judicial authority," said Marc Rotenberg, president and chief executive of the Electronic Privacy Information Center, a public interest research center in Washington.

Mark Rasch, an attorney who once prosecuted computer crimes at the Justice Department, agreed. "Such a decision would allow foreign countries to search your files in the United States if the company storing them happens to have an office in that country," he said.

The federal law governing stored communications was passed in 1986, before the development of electronic mail and the creation of the World Wide Web. Several technology companies say Congress, not the courts, should provide an answer to the privacy storage issue.

The justices will decide this case by late June.