Under threat of a court challenge, the Obama administration in 2010 revealed to Sprint the secret legal basis of a then-classified program that collected Americans’ phone records by the billions for counterterrorism purposes, according to newly declassified documents and interviews.

The company — the nation’s third-largest wireless provider — was the only firm to demand access to the legal rationale underpinning the National Security Agency program before its existence was revealed in June as a result of a leak from former NSA contractor Edward Snowden, current and former U.S. officials said.

But after being shown the documents, the company dropped its challenge and continued to turn over customers’ call-detail records to the NSA.

Civil liberties advocates seized on the case to argue that the disclosure of the program’s legal reasoning to the phone company alone was not sufficient to protect the public’s privacy rights.

“The real story here is the almost complete failure of the telecoms to protect their subscribers’ interests,” said Jameel Jaffer, deputy legal director of the American Civil Liberties Union, whose organization has filed a lawsuit contesting the program’s constitutionality and legality.

In January, President Obama ordered an end to the call-records program in its original form. But the political and legal history of the program still has not been fully told. Although several rulings by the Foreign Intelligence Surveillance Court were declassified last year, other opinions on the underlying statute, Section 215 of the USA Patriot Act, are being withheld by the Office of the Director of National Intelligence.

The name of the company shown the legal basis for the program in 2010 was redacted from documents released Wednesday by the director of national intelligence, James R. Clapper Jr. But a U.S. official familiar with the matter confirmed the firm was Sprint.

“Sprint believes that substantive legal grounding should be provided when the government requests customer information from carriers,” spokesman John Taylor said in a statement. “Sprint has a long-standing commitment to protecting our customers’ privacy and will challenge an order for customer information that we don’t think complies with the law.”

In an opinion declassified in September, a surveillance judge stated that “to date” no company that had received a court order had challenged it. While technically true, Sprint attorney Michael A. Sussmann raised concerns in 2009 that the program violated the law and had prepared a lengthy legal challenge, according to the U.S. official, who, like others, spoke on the condition of anonymity because of the matter’s sensitivity.

Last year, Sprint began to seek a way to counter the perception that no phone company had questioned the secret program’s legal foundation. Sprint felt the judge’s characterization was “unfair,” the U.S. official said. “Their feeling was, ‘Just because we didn’t formally oppose it doesn’t mean we didn’t question it.’ ”

The call-records program began in secret shortly after the Sept. 11, 2001, terrorist attacks, was put under court supervision in 2006 and was declassified last year. On a daily basis, the NSA collected phone numbers dialed and call duration and time — but not call content — from three major phone companies.

In early 2009, Sprint received an order saying that all customer call records had to be turned over to the government, officials said. In the summer and fall, the company’s executives met several times with Justice Department officials to understand how Section 215, which compelled companies to turn over records relevant to investigations, could be used to mandate the transfer of all call records.

Dissatisfied with their answers, Sussmann, the Sprint attorney, wrote a petition to challenge the order. In late 2009, shortly before the petition was to be filed, Robert S. Litt, the U.S. intelligence community’s top lawyer, pressed officials to provide the legal rationale to Sprint, according to a former administration official.

Intelligence officials then furnished several court rulings — in particular, a 2004 opinion written by Colleen Kollar-Kotelly, then chief judge of the surveillance court, according to the documents released Wednesday. Although the opinion related to the collection of e-mail addressing information, the legal rationale was identical.

The judge adopted the government’s reasoning that a large collection of data was necessary to find “unknown” terrorists who might be in contact with known suspects. The relevance standard, she said, “does not require a statistical ‘tight fit’ between” the massive collection and the “much smaller proportion” of data that might be relevant.

In January, after the public disclosure of the program, Verizon contested a similar court order to comply with the NSA collection. The challenge followed a federal court ruling in December that said the program was unconstitutional. The court assured Verizon it had considered the ruling and found the program to be legal and it dismissed the company’s challenge.