Phone records obtained by the government through a secret surveillance program disclosed last week helped to prevent "dozens" of terrorist acts, the director of the National Security Agency told a Senate hearing on Wednesday.

Army Gen. Keith Alexander provided the most detailed account so far from a government official of the program in which the agency collects phone records that then can be accessed under federal court permission to investigate suspected terrorists.

The scope of the secret program -- potentially involving phone records of every American -- set off a political firestorm when details emerged with publication of a leaked document.

Further leaks revealed other secret programs that collect computer activity and other information.

Critics on the right and left accused the government of going well beyond the intended reach of the Patriot Act enacted after the September 11, 2001, terrorist attacks on the United States.

NSA: Dozens of terror attacks stopped

Just Watched

Charges being sought against NSA leaker

Questioned by senators from both parties at a hearing on broader cybersecurity issues, Alexander provided a spirited defense for the programs he described as critical to counter-terrorism efforts.

"I think what we're doing to protect American citizens here is the right thing," he said. "Our agency takes great pride in protecting this nation and our civil liberties and privacy, and doing it in partnership with this committee, with this Congress, and with the courts."

Alexander added that he welcomed a public debate over protecting America while preserving civil liberties.

"To date, we've not been able to explain it because it's classified, so that issue is something that we're wrestling with," he said. "... This isn't something that's just NSA or the administration doing that and so on. This is what ... our nation expects our government to do for us. So, we ought to have that debate. We ought to put it out there."

In the end, he said, some aspects of the giant surveillance apparatus created after 9/11 would have to remain classified.

"And they should be, because if we tell the terrorists every way that we are going to track them, they will get through and Americans will die," he said.

Alexander also rejected the claim that former NSA contractor Edward Snowden, who admitted leaking the top-secret documents on electronic surveillance programs and is now in hiding, could tap into any American's phone or e-mail.

"I know of no way to do that," he said, calling Snowden's statement "false."

In an exchange with Democratic Sen. Patrick Leahy of Vermont, Alexander said he believed the program under Section 215 of the Patriot Act was "critical" in helping the intelligence community corroborate information on possible threats.

"It is dozens of terrorist events that these have helped prevent," Alexander said of the Section 215 program and another that collects information on foreign computer use.

He would not discuss specific disrupted plots, saying they were classified, but he told Leahy that the two programs together played a role in helping to stop a planned attack on the New York subway system.

Information developed overseas was passed along to the FBI, which was able to identify suspect Najibullah Zazi in Colorado and ultimately uncover a plot, he said. Zazi pleaded guilty to terror-related charges in 2010.

Senator: NSA leak was civil disobedience

Just Watched

Is the U.S. less safe after NSA leak?

In response to questions from senators about why the Section 215 program needed to collect billions of U.S. phone records, Alexander explained that the agency held the records for five years in the event that an investigation uncovered an overseas terrorist link to a specific area in the United States.

With a database of phone records, the agency can go "back in time" to figure out the number and date that a suspect called, he said.

"We won't search that unless we have some reasonable, articulable suspicion about a terrorist-related organization," Alexander said.

Once permission is granted, "we can now look and say, 'who was this guy talking to in the United States and why?'"

"The system just gives us back who he was talking to," Alexander explained. "But if you didn't collect it, how do you know who he was talking to?"

Obtaining further information, such as the content of the call, would require a court order, he said.

GOP Sen. Mike Johanns of Nebraska pressed Alexander on the issue, asking if the search could span "the breadth of telephone records."

"The American public is fearful that in this massive amount of data you get that there's the ability of the federal government to synthesize that data and learn something more than maybe what was ever contemplated by the Patriot Act," Johanns said.

Alexander will return to the panel on Thursday to give a classified briefing on the programs in order to provide more information, and he pledged to work with the committee to come up with more detailed explanations for the American public.

He explained his caution on Wednesday by saying revelations such as the classified documents about the secret programs were harmful to national security efforts.

"I would rather take a public beating and people think I am hiding something than to jeopardize the security of this country," Alexander said.

Bradley Manning and Edward Snowden both held jobs that gave them access to some of their country's most secret and sensitive intelligence. They chose to share that material with the world and are now paying for it.