WASHINGTON — The Foreign Intelligence Surveillance Court on Tuesday offered its most extensive public explanation for why it has allowed the government to keep records of all Americans’ phone calls, releasing a previously classified opinion in which it said the program was constitutional and did not violate Americans’ privacy rights.

While the once-secret call log program has been periodically reapproved by the court since 2006, it has come under criticism from members of Congress of both parties and civil libertarians since its existence came to public light in June after leaks by the former National Security Agency contractor Edward J. Snowden.

In a 29-page opinion that quoted the N.S.A. director, Keith Alexander, as saying the leaks had caused “significant and irreversible damage” to national security, Judge Claire V. Eagan, a federal judge in the Northern District of Oklahoma, declared that the program was lawful. So, she wrote, any decision about whether to keep it was a political question, not a legal one.

“This court is mindful that this matter comes before it at a time when unprecedented disclosures have been made about this and other highly sensitive programs designed to obtain foreign intelligence information and carry out counterterrorism investigations,” she wrote, adding: “In the wake of these disclosures, whether and to what extent the government seeks to continue the program discussed in this memorandum opinion is a matter for the political branches to decide.”