NEW YORK — The U.S. government has defended its use of a phone-tracking program that collects the telephone records of millions of Americans in a letter to a federal judge, saying it is a program monitored by all three branches of government that is necessary to learn the contacts of known or suspected terrorists and thwart terrorism.

The letter sent Thursday by assistant U.S. attorneys in Manhattan said the "highly sensitive and, in many respects, still classified intelligence-collection program" required the collection and storage of a large volume of information about unrelated communications to fight terrorism.

The letter, the first government response to a lawsuit filed by the American Civil Liberties Union against the Obama administration earlier this year, said the program "fills an intelligence gap highlighted by the attacks of 9/11" and had been repeatedly approved by multiple judges.

It said that under the program, the FBI obtains authorization from the Foreign Intelligence Surveillance Court to collect data from certain telecommunications service providers.

It said the National Security Agency archives the information and "queries the data, when strict standards are met" to detect communications between foreign terrorist organizations and their potential operatives in the United States, providing leads to the FBI or others in the intelligence community for counterterrorism purposes.

"The program has contributed to the disruption of multiple potential terrorist attacks in the United States and abroad," according to the letter.

The ACLU had asked a judge to find the program unconstitutional, saying the government's program exceeds the congressional authority provided by the Patriot Act, which Congress hurriedly passed after 9/11 and reauthorized in 2005 and 2010. President Barack Obama has defended the program and said privacy must be balanced with security.

In its letter, the government said the FISA Court's orders strictly limit the nature of the data the government can collect and the extent to which it can be reviewed.

It said the government is not permitted to listen to or record the contents of anyone's phone calls and information acquired under the court orders does not include cell-site location data or the names, addresses or identities of the parties to any communication.

The letter said information is limited to data such as originating and terminating telephone numbers and the date, time, and duration of each call.

"Additionally, the government is prohibited by the FISA Court's orders from indiscriminately sifting through the data," it said.

The letter said the database may only be queried for intelligence purposes where there is a reasonable articulable suspicion "based on specific facts" that an identifier, such as a phone number, is associated with a specific foreign terrorist organization previously identified and approved by the court.

"Consequently, only a very small fraction of the records acquired under this program is ever reviewed by intelligence analysts," the letter said.

It said that in 2012, fewer than "300 unique identifiers were authorized for query" under the standard.

According to the letter, congressional intelligence committees are regularly briefed on the program.

"Thus, the program has been approved and is rigorously overseen by all three branches of the government," the letter said.

The lawyers wrote that the ACLU is trying to stop a program "that plays an important role in the government's overall strategy to protect the American people from terrorist threats."

It said storing a large volume of information is necessary to ensure that a much smaller subset of terrorist-related phone records are preserved, since phone companies store data for a limited period. The letter added that aggregating the data is necessary as well to identify records that involve different telecommunications networks.

ACLU attorney Alex Abdo called the government's view of Americans' right to privacy "shockingly narrow."

"If the government is correct, then the NSA may warehouse all of our domestic communications now so long as it only searches for a subset of them later on," Abdo said in a statement. "The Constitution does not permit the government to cast a dragnet over every Americans' communications on the theory that the NSA might one day need them.

"There is also a tension between the government's public insistence that its collection of every Americans' phone records is lawful and its vigorous attempt to prevent that very question from being addressed by the court."