Members of the US Congress said they never intended to allow the National Security Agency to build a database of every phone call in America and threatened to curtail the government's surveillance authority.
But top Obama administration officials countered that the programme was legal and necessary to keep the US 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 Wednesday undercut Barack Obama's assurances that Congress had fully understood the expansion of government power it authorised repeatedly over the past decade.
The House Judiciary Committee hearing also represented perhaps the most public, substantive congressional debate on surveillance powers since the terrorist attacks of September 11, 2001.
Previous debates have been largely theoretical and legalistic, with officials in the Bush and Obama administrations keeping the details hidden as classified.
That changed in June when former NSA contractor Edward Snowden leaked documents revealing that the NSA collects every American's phone records.
The Obama administration says it needs a library of everyone's phone records so that when it finds a suspected terrorist, it can search its archives for the suspect's calling habits.
It says the database was authorised under a provision in the Patriot Act that Congress hurriedly passed after the 2001 attacks and reauthorised in 2005 and 2010.
The sponsor of that bill, James Sensenbrenner, a Republican, said on Wednesday that Congress meant only to allow seizures directly relevant to national security investigations.
No one expected the government to store all phone records to search later.
As Deputy Attorney General James Cole explained why that was necessary, Sensenbrenner cut him off and reminded him that his surveillance authority expires in 2015.
"And unless you realise you've got a problem," Sensenbrenner said, "that is not going to be renewed."
Jerry Nadler, a Democrat, said the problem was that the administration considered "everything in the world" relevant to fighting terrorism.
Later, Blake Farenthold, a Republican, asked whether the NSA could build similar databases of everyone's internet searches, hotel records and credit card transactions.
Robert Litt, general counsel in the Office of Director of National Intelligence, did not directly answer, saying it would depend on whether the government believed those records, like phone records, to be relevant to terrorism investigations.
After the phone surveillance became public, Obama assured Americans that Congress was well aware of what was going on.
"When it comes to telephone calls, every member of Congress has been briefed on this programme," he said. Whether lawmakers willingly kept themselves in the dark or were misled, it was apparent on Wednesday that one of the key oversight bodies in Congress remained unclear about the scope of surveillance, more than a decade after it was authorised.
For the first time, NSA deputy director John Inglis disclosed on Wednesday that the agency sometimes conducts "three-hop analysis".
That means the government can look at the phone data of a suspect terrorist, plus the data of all of his contacts, then all of those people's contacts, and finally, all of those people's contacts.
If the average person calls 40 unique people, three-hop analysis could allow the government to mine the records of 2.5 million Americans.
Meanwhile the American Civil Liberties Union said law enforcement agencies are using number plate scanners designed to track down criminals to build databases detailing the whereabouts of millions of US drivers.
The ACLU's new report, released on Wednesday, summarised the advocacy group's investigation last year into the way law enforcement agencies collect and store data from number plate readers, which are typically installed beside roads or on police cars.
Additional reporting by The New York Times