A New York state court has called on the firm to release tweets written by an activist who took part in the Occupy Wall Street protests last year.
The micro-blogging service disputes a judge's ruling that messages are owned by the firm rather than its users.
The American Civil Liberties Union commended the company for defending free speech rights.
Twitter's lawyer, Ben Lee, said: "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 case centres around Malcolm Harris, managing editor of the New Inquiry website.
He was arrested on 1 October along with hundreds of other campaigners during a march across 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's lawyer had tried to block access to the postings, but a judge ruled that once the messages had been sent they became the property of Twitter, meaning the defendant was not protected by Fourth Amendment protection against unlawful search and seizure.
Twitter's lawyers argued that the judge had misunderstood how the service worked, noting that the Stored Communications Act gave its members the right to challenge requests for information on their user history.
"This is a big deal," said the American Civil Liberties Union in a blog post.
"Law enforcement agencies... are becoming increasingly aggressive in their attempts to obtain information about what people are doing on the internet.
"If internet users cannot protect their own constitutional rights, the only hope is that internet companies do so."
One media analyst said Twitter's action also reflected its wider desire to avoid becoming caught up in litigation.
"Twitter, like any internet service provider, wants people who upload material to be responsible - it doesn't want to be in a position where it has to review all of the tweets," Benedict Evans from Enders Analysis told the BBC.
"It sees itself as being like an email provider and doesn't want to have to worry about issues of copyright (and) libel about other matters relating to what people post.
"That said, it can't totally avoid the issue. We have seen cases of US courts forcing email providers to hand over evidence, and Twitter has access to the data."