Washington (CNN) -- 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.
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.