Twitter has been ordered to hand over almost three months worth of messages from an Occupy Wall Street protester after losing a legal challenge to prosecutors' demands for the tweets.

The micro-blogging website had argued that the posts belonged to activist Malcolm Harris and as such it would be violating fourth amendment privacy rights if it were to disclose the communications without first receiving a search warrant.

But a Manhattan judge ruled on Monday that under a timeline set out by federal law, a warrant is only needed for the final day's worth of messages from Harris, who is accused of disorderly conduct in relation to a protest on the Brooklyn Bridge in October.

All other tweets prior to this date could legitimately be demanded by means of subpoena, it was ruled.

Harris was amongst several hundred Occupy Wall Street demonstrators arrested last year during a protest march across Brooklyn Bridge.

Prosecutors say that messages posted by Harris – who goes by the twitter handle @destructuremal – could show whether the defendant was aware that he was breaking police orders relating to the demo.

In January, the New York County district attorney's office issued a subpoena to Twitter, calling on the firm to hand over "any and all user information, including email address, as well as any and all tweets posted for the period 9/15/2011 – 12/31/2011".

Harris initially attempted to block the move, but was told that he had no proprietary interest to his own messages.

Twitter countered that this contradicts its own terms and conditions, which explicitly states that users "retain their right to any content they submit, post or display on or through". Moreover, in its own legal challenge to the subpoena, the firm accused prosecutors of trying to force its employees to violate federal law.

Lawyers for Twitter also argued that under the Uniform Act, prosecutors would need to obtain a subpoena in California before it could demand documents from a company based in that state.

Monday's ruling found that a search warrant was indeed needed for a final day's worth of tweets by Harris as they fell within a timeline laid out in federal law. All else was fair game for the prosecutors, the judge found.

The court will now review the material and provide the relevant tweets to the DA's office.

In a statement, Chief Assistant District Attorney Daniel Alonso said he was "pleased that the court has ruled for a second time that the Tweets at issue must be turned over".

He added: "We look forward to Twitter's complying and to moving forward with the trial."

Responding to the development, Harris's attorney Martin Stolar said: "I'm not surprised by the ruling, but I'm still disappointed by it." He added that he and Twitter could still mount a further challenge, stating that there was still "plenty of time to do that" before his client's next court appearance.

Stolar suggested that the latest decision shows that the court fails to take into consideration 21st century developments when it comes to what should be covered under the fourth amendment. "That is somewhat bothersome," he added.