A legal battle over the scope of US government surveillance took a turn in favour of the National Security Agency on Friday with a court opinion declaring that bulk collection of telephone data does not violate the constitution.

The judgement, in a case brought before a district court in New York by the American Civil Liberties Union, directly contradicts the result of a similar challenge in a Washington court last week which ruled the NSA's bulk collection program was likely to prove unconstitutional and was "almost Orwellian" in scale.

Friday's ruling makes it more likely that the issue will be settled by the US supreme court, although it may be overtaken by the decision of Barack Obama on whether to accept the recommendations of a White House review panel to ban the NSA from directly collecting such data.

But the ruling from Judge William Pauley, a Clinton appointee to the Southern District of New York, will provide important ammunition for those within the intelligence community urging Obama to maintain the programme.

Judge Pauley said privacy protections enshrined in the fourth amendment of the US constitution needed to be balanced against a government need to maintain a database of records to prevent future terrorist attacks. “The right to be free from searches is fundamental but not absolute,” he said. “Whether the fourth amendment protects bulk telephony metadata is ultimately a question of reasonableness.”

Pauley argued that al-Qaida's “bold jujitsu” strategy to marry seventh century ideology with 21st century technology made it imperative that government authorities be allowed to push privacy boundaries.

“As the September 11 attacks demonstrate, the cost of missing such a threat can be horrific,” he wrote in the ruling. “Technology allowed al-Qaida to operate decentralised and plot international terrorist attacks remotely. The bulk telephony metadata collection programme represents the government's counter-punch: connecting fragmented and fleeting communications to re-construct and eliminate al-Qaida's terror network.”

The ACLU case against the NSA was dismissed primarily on the grounds that bulk collection was authorised under existing laws allowing “relevant” data collection to be authorised by secret US courts.

Judge Pauley took a more sympathetic view of this relevance standard than many lawmakers in Congress, although he acknowledged it was “problematic” that many were not aware of how widely the law was being interpreted before disclosures by NSA whistleblower Edward Snowden.

“The ACLU argues that the category at issue – all telephony metadata – is too broad and contains too much irrelevant information. That argument has no traction here. Because without all the data points, the government cannot be certain it is connecting the pertinent ones,” said Pauley.

“There is no way for the government to know which particle of telephony metadata will lead to useful counterterrorism information ... Armed with all the metadata, NSA can draw connections it might otherwise never be able to find. The collection is broad, but the scope of counterterrorism investigations is unprecedented.”

The ACLU said it would appeal the decision, starting in the New York circuit. “We are extremely disappointed with this decision, which misinterprets the relevant statutes, understates the privacy implications of the government’s surveillance and misapplies a narrow and outdated precedent to read away core constitutional protections,” said Jameel Jaffer, ACLU deputy legal director.

“As another federal judge and the President’s own review group concluded last week, the National Security Agency’s bulk collection of telephony data constitutes a serious invasion of Americans’ privacy. We intend to appeal and look forward to making our case in the second circuit.”

Judge Pauley said his ruling did not mean it was right to continue with the program, which he acknowledged was a “blunt tool” that “imperils the civil liberties of every citizen” if unchecked. “While robust discussions are under way across the nation, in Congress, and at the White House, the question for this court is whether the government's bulk telephony metadata program is lawful. The court finds it is,” he wrote. “But the question of whether that program should be conducted is for the other two coordinate branches of government to decide.”