A US judge has ruled that the gathering of phone records by the National Security Agency is likely to be unlawful, raising "serious doubts" about the value of the NSA’s counter-terrorism programme.

"I cannot imagine a more 'indiscriminate' and 'arbitrary invasion' than this systematic and high-tech collection and retention of personal data on virtually every single citizen," US District Judge Richard Leon, wrote in a 68-page ruling.

The US Department of Justice says it is reviewing the ruling in a case brought by Larry Klayman, a conservative lawyer, and Charles Strange, described in court documents as the father of a cryptologist technician for the NSA who was killed in Afghanistan in 2011.

The judge ordered the government to stop collecting data about the two plaintiffs, who were Verizon Communications Inc customers. Verizon declined to comment.

"We believe the programme is constitutional as previous judges have found," Department of Justice spokesman Andrew Ames said in a statement.

Mr Leon suspended enforcement of his injunction against the programme "in light of the significant national security interests at stake in this case and the novelty of the constitutional issues" pending an expected appeal by the government. A US official said an appeal was likely.

Mr Leon also expressed scepticism of the programme's value, writing that the government could not cite a single instance in which the data collected actually stopped an imminent attack.

In order for the programme to be constitutional, the government must show its effectiveness outweighs privacy interests.

Edward Snowden, in a statement sent by journalist Glenn Greenwald, applauded the ruling.

"I acted on my belief that the NSA's mass surveillance programmes would not withstand a constitutional challenge, and that the American public deserved a chance to see these issues determined by open courts," he said.

"Today, a secret programme authorised by a secret court was, when exposed to the light of day, found to violate Americans' rights. It is the first of many."         

Meanwhile, Brazil has stated that it is not planning on granting asylum to Mr Snowden after the former NSA contractor offered to help investigate revelations that the NSA had spied on Brazilians, including President Dilma Rousseff.

Mr Snowden is currently living in Russia under temporary asylum that is due to expire in August 2014, and had previously asked for asylum in Brazil in a request that had gone unanswered.