A U.S. District Court judge in New York ruled Friday that the National Security Agency's telephone metadata collection program was legal, rejecting a lawsuit by the American Civil Liberties Union against it, and setting up a conflict with an earlier ruling that the program was "likely unconstitutional."

Judge William Pauley specifically invoked the 9/11 attacks to say the program was needed to ward off terrorism.

His ruling states at the very beginning: "The Sept. 11 terrorist attacks revealed in the starkest terms just how dangerous and interconnected the world is. While Americans depend on technology for the conveniences of modernity, al Qaeda plotted in a seventh-century milieu to use that technology against us. It was a bold jiujitsu. And it succeeded because conventional intelligence-gathering could not detect the defuse filaments connecting al Qaeda."

He added later that "telephony metadata would have furnished the missing information and might have permitted the NSA to notify the Federal Bureau of Investigation" of the impending attacks.

The ruling runs directly contrary to one two weeks ago by Judge Richard Leon of the Federal District Court for the District of Columbia that found that the NSA's activities were "likely unconstitutional." Leon stated in his Dec. 16 ruling: "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 for purposes of querying it and analyzing it without judicial approval."

In a statement, the ACLU said: "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."

The contrasting rulings from federal courts in different judicial circuits heightens the probably that the Supreme Court will have to rule on the matter.