A federal judge today (Dec. 16) knocked out the legal underpinnings supporting the National Security Agency's (NSA) bulk collection of domestic telephone metadata, ordering that the government end the program.

"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," Justice Richard Leon wrote in his memorandum granting a preliminary injunction against the NSA.

However, Justice Leon, of the U.S. District Court for the District of Columbia, commonly known as the D.C. Circuit Court, stayed his order pending a government appeal.

But he warned that "should my ruling be upheld, this order will go into effect forthwith."

MORE: '60 Minutes' BIOS Plot May Be NSA Invention

Leon's 68-page ruling finds that the Supreme Court's 1979 ruling in Smith v. Maryland, which upheld the right of police to place a "pen register" on a telephone line without a warrant, is not sufficient justification for the NSA's daily collection of millions of telephone records.

A pen register is a simple device that records all the telephone numbers sending and receiving calls from a telephone line.

In Smith v. Maryland, investigators had placed a pen register in the offices of a telephone company to track a specific line.

According to a piece published in this week's New Yorker magazine, in 2004, then-NSA Director Gen. Michael Hayden persuaded Foreign Intelligence Surveillance Court Judge Colleen Kollar-Kotelly to approve the collection of bulk metadata on the basis of the Smith ruling. (Kollar-Kotelly is now a colleague of Leon's on the D.C. Circuit Court bench.)

Today, Leon found that argument long out of date.

"When do present-day circumstances — the evolutions in the government's surveillance capabilities, citizens' phone habits and the relationship between the NSA and telecom companies — become so thoroughly unlike those considered by the Supreme Court 34 years ago that a precedent like Smith simply does not apply?" Leon asked.

"The answer, unfortunately for the Government," he wrote, "is now."

MORE: Can You Hide Anything From the NSA?

Leon's memorandum responds to motions for preliminary injunctions in two lawsuits filed by legal gadfly Larry Klayman, a conservative activist and lawyer who has repeatedly sued the federal government over the past 20 years.

Klayman's first lawsuit against the NSA, which Leon refers to as Klayman I, was filed June 6 of this year, the day after the first NSA documents leaked by Edward Snowden were published in The Guardian and The Washington Post. It seeks to end bulk collection of telephone metadata.

The second lawsuit, or Klayman II, was filed June 12, following the exposure of the NSA's PRISM program, and expanded the grievances to include collection of Internet metadata.

Preliminary injunctions are normally granted when a judge finds that ongoing conduct of one of the parties is harming the other, even before the final ruling is made. Injunctions often indicate how the court will rule.

Klayman had filed the motions for preliminary injunction on the ground that the NSA's continued collection of bulk metadata was causing harm to himself and four fellow plaintiffs.

Leon excluded Internet metadata from his ruling because Director of National Intelligence James Clapper had told Sen. Ron Wyden (D-Ore.) that domestic collection of Internet metadata had ended in 2011 "and therefore there is no possible ongoing harm that could be remedied by injunctive relief."

Regarding the collection of Internet metadata overseas, Leon ruled that it could not be shown to have targeted any of the plaintiffs' communications.

But, he wrote, "the court concludes that plaintiffs have standing to challenge the constitutionality of the government's bulk collection and querying of phone record metadata ... and that they will suffer irreparable harm absent preliminary injunctive relief."

MORE: How the NSA Gets Into Your Smartphones

Leon furthermore questioned whether the collection of bulk metadata was effective at all.

"The government does not cite a single instance," he wrote, "in which analysis of the NSA's bulk metadata collection actually stopped an imminent attack, or otherwise aided the government in achieving any objective that was time-sensitive in nature."

Nevertheless, "in light of the significant national security interests at stake in this case and the novelty of the constitutional issues," Leon wrote, "I will stay my order pending appeal."

But, he added, "I fully expect that during the appellate process, which will consume at least the next six months, the government will take whatever steps necessary to prepare itself to comply with this order when, and if, it is upheld.

"Suffice it to say," Justice Leon said in conclusion, "requesting further time to comply with this order months from now will not be well received and could result in collateral sanctions."

Follow Paul Wagenseil at @snd_wagenseil. Follow Tom's Guide at @tomsguide, on Facebook and on Google+.