The next day, the phone company and the Justice Department jointly petitioned the court to extend the time period for the company to challenge the order requiring it to turn over its customers’ records. It noted that the carrier had been raising questions about the legality of the program since July 2009.

Judge John D. Bates of the surveillance court granted the motion, saying the documents would remain sealed in all other respects, the newly declassified documents show. He also granted the motion to give the phone company more time to think about challenging the order.

Three days later, the Justice Department asked the court to put more information in the order to the phone company about the court’s legal conclusions. No other documents related to the episode were disclosed.

Judge Eagan’s opinion was written after the program’s existence was leaked, and was the first time that a judge on the court detailed a rationale for why it was legal, although the court had by then been periodically ordering phone companies to comply with it for seven years.

Her opinion was written against the backdrop of sharp questions about whether the program was lawful and whether the surveillance court — which hears arguments only from the government before issuing secret rulings — was equipped to deal with complex legal analysis about surveillance law and privacy rights, as opposed to just approving wiretap applications.

In January, another phone company — first identified by The Post as Verizon — challenged an order for the program, but Judge Rosemary M. Collyer rejected it. She portrayed the challenge as the first by a carrier and cited Judge Eagan’s statement.

The national security official said the court papers concerning the January 2010 episode had been declassified at the request of the first carrier.