Updated

A federal judge in New York has ruled the National Security Agency's massive data collection program is legal, one week after another federal judge ruled the opposite.

The conflicting rulings increase the likelihood that the challenges could someday end up before the Supreme Court.

The ruling on Friday came from District Judge William H. Pauley III, in the case of the ACLU vs. James Clapper, the director of national intelligence. The judge agreed with the federal government's request to dismiss the case.

"No doubt, the bulky telephony metadata collection program vacuums up information about virtually every telephone call to, from, or within the United States," the judge wrote.

But he added: "As the September 11th attacks demonstrate, the cost of missing such a thread can be horrific. Technology allowed Al Qaeda to operate decentralized and plot international terrorist attacks remotely. The bulky telephone metadata collection program represents the Government's counter-punch: connecting fragmented and fleeting communications to re-construct and eliminate al-Qaeda's terror network."

More On This...

    After the ruling, the ACLU said it would appeal to the Second Circuit Court of Appeals.

    "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," Jameel Jaffer, ACLU deputy legal director, said in a statement.

    The Justice Department issued a brief statement: "We are pleased the court found the NSA's bulk telephony metadata collection program to be lawful."

    The decision was a victory for the Obama administration after a string of setbacks. Last week, U.S. District Court Judge Richard Leon, in Washington, D.C., ruled that the NSA phone record collection program likely violates the Constitution.

    The ruling was the first major legal defeat for the NSA since former contractor Edward Snowden began exposing secrets about the NSA's data collection over the summer.

    Leon, unlike Pauley, questioned the program's effectiveness in helping officials conduct "time-sensitive investigations in cases involving imminent threats of terrorism."

    Leon called the program "almost-Orwellian technology," and said: "Surely such a program infringes on 'that degree of privacy' that the founders enshrined in the Fourth Amendment."

    A task force charged with reviewing NSA policies also recommended a series of changes earlier this month. President Obama, before leaving for vacation in Hawaii, said he would be making a statement about the future of the NSA after he returns.

    After Pauley's ruling, NSA defender Rep. Peter King, R-N.Y., said the decision "preserves a vital weapon for the United States in our war against international terrorism."

    "I would hope that Judge Pauley's opinion will lessen at least some of the adulation for Edward Snowden as well as the rabid anti-NSA hysteria which has become so pervasive," he said.

    The Associated Press contributed to this report.