Seven years after former National Security Agency contractor Edward Snowden blew the whistle on the mass surveillance of Americans' telephone records, a US appeals court has found the programme was unlawful.

It also found that the US intelligence leaders who publicly defended it were not telling the truth.

The ruling said the warrantless telephone dragnet that secretly collected millions of Americans' telephone records violated the Foreign Intelligence Surveillance Act and may well have been unconstitutional.

Mr Snowden, who fled to Russia in the aftermath of the 2013 disclosures and still faces US espionage charges, said on Twitter that the ruling was a vindication of his decision to go public with his evidence.

"I never imagined that I would live to see our courts condemn the NSA's activities as unlawful and in the same ruling credit me for exposing them," Mr Snowden said in a message posted on Twitter.

Evidence that the NSA was secretly building a vast database of US telephone records - the who, the how, the when, and the where of millions of mobile calls - was the first and arguably the most explosive of the Snowden revelations published by the Guardian newspaper in 2013.

Up until that moment, top intelligence officials publicly insisted the NSA never knowingly collected information on Americans at all.

After the programme's exposure, US officials fell back on the argument that the spying had played a crucial role in fighting domestic extremism, but the Ninth Circuit ruled that those claims were "inconsistent with the contents of the classified record."

Watchdog groups including the American Civil Liberties Union have welcomed the judges' verdict.

"Today's ruling is a victory for our privacy rights," the ACLU said in a statement, saying it "makes plain that the NSA's bulk collection of Americans' phone records violated the Constitution."