The US secretary of state, Hillary Clinton, praised the role of social networks such as Twitter in promoting freedom – at the same time as the US government was in court seeking to invade the privacy of Twitter users.

Lawyers for civil rights organisations appeared before a judge in Alexandria, Virginia, battling against a US government order to disclose the details of private Twitter accounts in the WikiLeaks row, including that of the Icelandic MP Birgitta Jonsdottir, below.

The move against Twitter has turned into a constitutional clash over the protection of individual rights to privacy in the digital age.

Clinton, in a speech in Washington, cited the positive role that Twitter, Facebook and other social networks played in uprisings in Tunisia and Egypt. In a stirring defence of the internet, she spoke of the "freedom to connect".

The irony of the Clinton speech coming on the day of the court case was not lost on the constitutional lawyers battling against the government in Alexandria. The lawyers also cited the Tunisian and Egyptian examples. Aden Fine, who represents the American Civil Liberties Union, one of the leading civil rights groups in the country, said: "It is very alarming that the government is trying to get this information about individuals' communications. But, also, above all, they should not be able to do this in secret."

The court case, which is turning into a cause celebre in the US, centres round the release of tens of thousands of Pentagon and state department classified documents by WikiLeaks. Outraged by the leaks, the US has set up a grand jury in secret, based in Alexandria, to investigate whether grounds can be found for a criminal case against WikiLeaks' founder, Julian Assange. As part of that investigation the grand jury ordered Twitter to disclose the details of the accounts of WikiLeaks and three people said to be linked to the organisation.

The investigation also covers Bradley Manning, the US soldier who was based in Iraq and is suspected of being behind the leak. He is being held in jail in Virginia.

Clinton tried to reconcile the US administration's support for the internet as a motor for change in the Middle East, China and elsewhere with its fury over WikiLeaks. She said: "Liberty and security. Transparency and confidentiality. Freedom of expression and tolerance. There are times when these principles will raise tensions and pose challenges, but we do not have to choose among them. And we shouldn't. Together they comprise the foundation of a free and open internet."

She added that the US backed internet freedom and encouraged other countries to do the same: "Leaders worldwide have a choice to make. They can let the internet in their countries flourish, and take the risk that the freedoms it enables will lead to a greater demand for political rights. Or they can constrict the internet, choke the freedoms it naturally sustains—and risk losing all the economic and social benefits that come from a networked society."

In courtroom 500 in Alexandria, the lawyers were arguing that the government orders be declared unlawful and that they should also be made public. One of the lawyers, John Keker, told the court it was "ironic" that the case was being heard against the backdrop of the Tunisian and Egyptian uprisings. He argued that if the government request was successful it would allow the government to intrude into the lives of individuals previously protected by constitutional rights. "This is something brand new," he said.

He added that Twitter, as a US company, was protected by the constitution. "The fact that some non-US citizens use Twitter does not make the constitution go away," Keker said.

Manning is almost certain to face trial in the US later this year but so far the US justice department has failed to find grounds for a criminal case against Assange, who is currently in the UK.

The court hearing broke up without any ruling by the judge.