WASHINGTON - In a heated confrontation over domestic spying, members of Congress said Wednesday that they never intended to allow the National Security Agency to build a database of every phone call in America. And they threatened to curtail the government's surveillance authority.

Top Obama administration officials countered that the once-secret program was legal and necessary to keep America safe. And they left open the possibility that they could build similar databases of people's credit-card transactions, hotel records and Internet searches.

The clash on Capitol Hill undercut President Obama's assurances that Congress had fully understood the dramatic expansion of government power it authorized repeatedly.

The House Judiciary Committee hearing also represented perhaps the most public, substantive congressional debate on surveillance powers since the 9/11 terrorist attacks.

That changed last month when former government contractor Edward Snowden leaked documents revealing that the NSA collects every American's phone records.

The Obama administration says it needs to be able to search its archives for any suspected terrorist's calling habits. It says the database was authorized under a provision in the Patriot Act that Congress passed after 9/11 and reauthorized in 2005 and 2010.

The sponsor of that bill, Rep. James Sensenbrenner, R-Wis., said Wednesday that Congress meant only to allow seizures directly relevant to national security investigations.

As Deputy Attorney General James Cole testified, Sensenbrenner cut him off and reminded him that his surveillance authority expires in 2015.

"And unless you realize you've got a problem," Sensenbrenner said, "that is not going to be renewed."