The American Civil Liberties Union said Tuesday it had filed a lawsuit on behalf of organizations including the Wikimedia Foundation and the conservative Rutherford Institute against the U.S. National Security Agency and the U.S. Department of Justice, challenging the American government's mass surveillance program.

The lawsuit alleges that the NSA's mass surveillance of internet traffic, often called "upstream" surveillance, violates the First Amendment of the U.S. Constitution, which protects freedom of speech and association, and the Fourth Amendment, which protects against unreasonable search and seizure.

The NSA and its partner spy agencies tap into the fibre-optic cables that carry internet traffic to collect hundreds of millions of emails and other internet communications, as part of their intelligence gathering.

"This kind of dragnet surveillance constitutes a massive invasion of privacy, and it undermines the freedoms of expression and inquiry as well," ACLU staff attorney Patrick Toomey said in a statement.

We are asking the court to order an end to the NSA's dragnet surveillance of internet traffic -Wikipedia founder Jimmy Wales

Organizations party to the lawsuit also include Amnesty International USA, PEN American Center, the Nation magazine, Human Rights Watch, the National Association of Criminal Defense Lawyers, Global Fund for Women, and Washington Office on Latin America.

"By tapping the backbone of the internet, the NSA is straining the backbone of democracy," Lila Tretikov, executive director of the Wikimedia Foundation, which runs Wikipedia, wrote in a blog post.

The lawsuit follows the ACLU's failed attempt in 2013 to challenge the NSA's warrantless wiretapping program, which was shot down by the U.S. Supreme Court on grounds that the plaintiffs could not prove that they had been spied on.

Whistleblower Edward Snowden, a former NSA contractor, provided documents exposing massive snooping on millions of people's communications by the U.S. spy agency and its partners. (The Guardian/Associated Press)

The NSA's current practices exceed the authority granted by the Foreign Intelligence Surveillance Act that the U.S. Congress amended in 2008, Wikimedia said.

"We are asking the court to order an end to the NSA's dragnet surveillance of internet traffic," Wikipedia founder Jimmy Wales wrote in an opinion piece in the New York Times.

The NSA has authorizations to target foreigners outside the U.S. with its spying, but a wave of leaked documents provided by former agency contractor Edward Snowden have revealed that its snooping is far more extensive, sweeping up the communications of millions of Americans.

The leaked documents show, among other things, that the NSA has hacked telecom companies in Europe and the U.S., installed malware into computer operating systems, tunnelled into Hotmail and other sites to snoop on emails and private chats, spied on allied countries' heads of state, and developed the ability to track the whereabouts and communications of most ordinary citizens.

In doing so, the NSA appeared to break the law thousands of times, according to its own internal documents.

A British tribunal has also ruled that Britain's GCHQ spy agency acted unlawfully in accessing data on millions of people in Britain that had been collected by the NSA.​

Major U.S. technology companies suffering from the fallout of the NSA's mass surveillance programs are also uniting to shore up their defences against government intrusion.

The NSA and the DoJ did not immediately respond to requests for comment.