From left, Deputy National Security Agency Director Chris Inglis, National Security Agency Director Gen. Keith Alexander, Director of National Intelligence James Clapper and Deputy Attorney General James Cole, testify on Capitol Hill in Washington, Tuesday, Oct. 29, 2013, before the House Intelligence Committee. AP Photo/ Evan Vucci

The head of the National Security Agency defended the intelligence agency as acting within legal boundaries Tuesday, as he sought to defuse growing controversies over the U.S. spying on its European allies and the collection of U.S. phone and email records.

General Keith Alexander, director of the NSA, offered an impassioned defense of the intelligence agency, telling the House of Representatives Intelligence Committee that it is focused on preventing attacks on Americans and its allies and operates under strict oversight.

"It is much more important for this country that we defend this nation and take the beatings than it is to give up a program that would result in this nation being attacked," Alexander said.

Under sympathetic questioning from the committee chairman, Representative Mike Rogers, Alexander called media reports in Europe alleging that the NSA collected data on tens of millions of phone calls in France, Spain and Italy "completely false."

Some of the data referenced in documents leaked by former NSA contractor Edward Snowden was collected not just by the NSA itself but was also "provided to NSA by foreign partners," he said. "This is not information that we collected on European citizens. It represents information that we and our NATO allies have collected in defense of our countries and in support of military operations."

Rogers warned that collecting foreign intelligence was important to protecting Americans and allies from terrorism.

"Every nation collects foreign intelligence. That is not unique to the United States," Rogers said in prepared opening remarks at the committee hearing. "What is unique to the United States is our level of oversight, our commitment to privacy protections and our checks and balances on intelligence collection."

At the hearing, witnesses included Alexander, NSA Deputy Director Chris Inglis, Director of National Intelligence James Clapper and Deputy Attorney General James Cole.

Protesters in the hearing room held signs that said "stop spying on us" and yelled "lies, lies and more lies."

The intelligence chiefs appeared against a backdrop of angry accusations by European allies that the United States spies on their leaders and citizens.

The loudest protests have come from Germany over reports of U.S. monitoring of Chancellor Angela Merkel's communications. A German media report last week said the United States monitored her cellphone. The White House did not deny the report but has said no such surveillance is taking place now.