US court has ordered Twitter to release old messages and details about a user arrested during an Occupy Wall Street protest in New York.
The micro-blogging firm contested the subpoena, saying the tweets were owned by users rather than the company.
But a judge said defendant Malcolm Harris' privacy would not be violated if the material was handed over.
Earlier, the American Civil Liberties Union commended Twitter for defending free speech rights.
"If you post a tweet, just like if you scream it out the window, there is no reasonable expectation of privacy," Judge Matthew Sciarrino wrote in his decision.
Nevertheless, the judge said he would personally review the information and would only release the relevant sections to prosecution and defence lawyers.Ownership dispute
The case centres around Mr Harris, managing editor of the New Inquiry website, a cultural magazine site.
He was arrested on 1 October - along with hundreds of other campaigners - during a march across New York's Brooklyn Bridge.
Prosecutors claim tweets by Mr Harris would reveal that he was "well-aware of police instructions" ordering protesters not to block traffic.
Mr Harris, and others, say they thought police had given them permission to march on the road.
Prosecutors have asked to see tweets posted by Mr Harris between 15 September and 31 December.
Mr Harris's lawyer had tried to block access to the postings, but the judge ruled that once the messages had been sent they became the property of Twitter. That would mean the defendant was not protected against unlawful search and seizure under the Fourth Amendment of the US constitution.
But Twitter challenged the subpoena, arguing that the judge had misunderstood how the service worked.
Twitter's lawyer, Ben Lee, said during earlier hearings: "Twitter's terms of service make absolutely clear that its users 'own' their own content. Our filing with the court reaffirms our steadfast commitment to defending those rights for our users."
The firm also said the Stored Communications Act gave its members the right to challenge requests for information on their user history, and that the micro-blogging firm did not want to take on legal battles that its users could pursue independently.
"We look forward to Twitter's complying and to moving forward with the trial," the district attorney's office said after the judge's ruling.
But Twitter expressed disappointment, saying: "We continue to have a steadfast commitment to our users and their rights."
Mr Harris' case has been set to go to trial in December.