Judge Pauley began his opinion with an anecdote. In the months before Sept. 11, he said, the N.S.A. intercepted seven calls made to a Qaeda safe house in Yemen from the United States. They were from Khalid al-Mihdhar, who was living in San Diego and would become one of the hijackers.

But the security agency “could not capture al-Mihdhar’s telephone number,” the judge wrote, and “N.S.A. analysts concluded mistakenly that al-Mihdhar was overseas and not in the United States.”

“Telephony metadata would have furnished the missing information and might have permitted the N.S.A. to notify the Federal Bureau of Investigation of the fact that al-Mihdhar was calling the Yemeni safe house from inside the United States,” Judge Pauley wrote.

Judge Leon, in Washington, took the opposite view, saying the government had failed to make the case that the program is needed to protect the nation. “The government does not cite a single instance in which analysis of the N.S.A.’s bulk metadata collection actually stopped an imminent attack, or otherwise aided the government in achieving any objective that was time-sensitive in nature,” he wrote.

The presidential review group took a middle ground, though it seemed to lean toward Judge Leon’s position. It said the security agency “believes that on at least a few occasions” the program “has contributed to its efforts to prevent possible terrorist attacks, either in the United States or somewhere else in the world.” But it added that its own review suggested that the program “was not essential to preventing attacks,” and that less intrusive measures would work.

The group recommended that bulk storage of telephone records by the government be halted in favor of “a system in which such metadata is held instead either by private providers or by a private third party.” Access to the data, it said, should require a court order.

The two judges did not limit their disagreements to how well the program worked. They also drew different conclusions about its constitutionality.