A federal judge in New York City on Friday ruled that the National Security Agency's massive phone surveillance network is legal, giving the Obama administration a judicial victory at a time when it's trying to defend the scope and constitutionality of the secretive programs.

“While robust discussions are underway across the nation, in Congress, and at the White House, the question for the court is whether the government’s bulk telephony metadata program is lawful. The court finds it is,” U.S. District Judge William Pauley said, dismissing a lawsuit filed by the American Civil Liberties Union.

The ruling came after another federal judge earlier this month said the NSA’s collection of bulk phone data from millions of Americans was likely unconstitutional but placed the ruling on hold pending a government appeal.

With the conflicting decisions in the lower courts, the Supreme Court will likely weigh in on the legality of the programs.

Still, the Obama administration welcomed the new ruling.

"We are pleased the court found the NSA's bulk telephony metadata collection program to be lawful," said Justice Department spokesman Peter Carr.

In the latest ruling, the judge argued that the NSA's surveillance techniques, exposed in leaks by former government contractor Edward Snowden, could have aided the intelligence community -- had they been in place -- ahead of the Sept. 11 terrorist attacks.

Obama in January will reveal his long-awaited NSA reforms after an outside panel recommended that phone companies, rather than the government, store Americans’ metadata.

Privacy rights advocates and civil liberties groups are concerned that Obama will offer only minor changes to the programs rather than fundamentally increase oversight of the secretive NSA surveillance.

“I'm taking this very seriously because I think, as I've said before, this is a debate that needed to be had,” Obama said in his last news conference of 2013, promising “a pretty definitive statement about all of this in January.”

In his ruling, Pauley alluded to a debate that will consume Washington in the coming year.

“The question of whether the program should be conducted,” the federal judge said, “is for the other two coordinate branches of government to decide.”