President Obama on Friday defended the government's collection of data on the phone records of millions of Americans, saying that it was a modest encroachment on privacy and one he thinks is both lawful and justified in order to identify terrorists plotting to attack the United States.

Obama emphasized that the government does not collect information on individual callers or eavesdrop on Americans' conversations without a warrant. He said he would welcome a debate on the classified surveillance effort as well as the previously secret workings of a second program that gathers the e-mails and other digital content of targeted foreigners outside the United States from major American Internet companies.

The programs "make a difference in our capacity to anticipate and prevent possible terrorist activity," Obama said.

Revelations about the programs in The Washington Post and the Guardian newspaper have opened up a debate that previously had been limited to the cryptic warnings of some members of Congress who were briefed on but troubled by the surveillance efforts. Some lawmakers who do not serve on the intelligence committees said they had no knowledge of the programs.

"Did I know about it? No, I didn't," said Rep. Gerald E. Connolly (D-Va.), who said he was unconvinced by the president's assurances that surveillance efforts are constrained by congressional oversight and the federal courts. "That's the lawyer in him speaking. .โ€‰.โ€‰. The way bureaucracies work, we stumble into invasions of privacy. We want information it's unwise to seek or to possess."

The National Security Agency acknowledges that Americans' communications can be inadvertently collected, but U.S. intelligence agencies have declined to provide Congress with an estimate on how often that has happened, despite repeated requests for that information.

In his remarks, Obama said it was "healthy for our democracy" to have an open discussion about the balance between privacy and security concerns but also said he rued the leaks of classified information that prompted the current debate.

"If every step that we're taking to try to prevent a terrorist act is on the front page of the newspapers or on television, then presumably the people who are trying to do us harm are going to be able to get around our preventive measures," Obama said during an event in Northern California. "That's why these things are classified. But that's also why we've set up congressional oversight. These are the folks you all vote for as your representatives in Congress, and they're being fully briefed on these programs."

The Obama administration has aggressively pursued leak investigations. In one case, it swept up the phone records of Associated Press journalists; in another, it identified a Fox News journalist as a "co-conspirator" for soliciting classified information.

The career intelligence officer who disclosed details of the online data-mining program to The Post said he acted out of a sense that the NSA has exceeded the privacy expectations of Americans. The source thinks he is likely to be exposed and is prepared for that possibility. One Justice official, speaking on the condition of anonymity, said that the department is at "the start of the process" of determining if an investigation of the leaks is appropriate.

The Guardian also reported Friday that GCHQ, Britain's equivalent of the NSA, has been secretly gathering intelligence from the same Internet companies through an operation set up by the NSA.

According to documents obtained by the Guardian, the program would appear to allow GCHQ to circumvent the formal legal process required in Britain to seek personal material such as ยญe-mails, photos and videos from an Internet company based outside of the country.

Several companies contacted by The Post said they did not allow direct government access to their servers and said that they responded only to court-sanctioned requests for information. Government officials also stressed that any information obtained is targeted and backed by law and the courts. The program was authorized in 2008 when Congress passed the FISA Amendments Act.

On Friday, Obama emphasized that both of the newly disclosed surveillance programs "have been authorized by broad, bipartisan majorities repeatedly since 2006. .โ€‰.โ€‰. It's important to understand that your duly elected representatives have been consistently informed on exactly what we're doing."

Former FBI official and CBS senior correspondent John Miller said the program that relies on Internet data, known as PRISM, helped break up a 2009 plot to attack the subway system in New York City. In that case, he said, the intelligence community was monitoring the IP address of an infrequently used dropbox linked to Rashid Rauf, an al-Qaeda bombmaker. When there was contact between the dropbox and an IP address in Aurora, Colo., investigators were led to Najibullah Zazi, an Afghan American who subsequently pleaded guilty to planning suicide attacks in New York.

Sens. Ron Wyden (D-Ore.) and Mark Udall (D-Colo.) said in a joint statement Friday they "remain unconvinced that the secret Patriot Act collection has actually provided any uniquely valuable intelligence. "

The two programs disclosed this week are part of the vast expansion of surveillance that took place after the Sept. 11, 2001, terrorist attacks. In the immediate aftermath, Congress hurriedly passed the USA Patriot Act, which, among other things, loosened the rules on the government's gathering of commercial records for investigations. One aspect of the legislation, known as Section 215 or the "business records" provision, allowed authorities to compel companies to turn over suspects' records from a host of sources including hotels, banks and religious institutions.

Orders compelling companies to turn over the information are issued by judges on the Foreign Intelligence Surveillance Court and originally required U.S. investigators to show they had "reasonable grounds to believe" that the records sought were "relevant to an authorized investigation .โ€‰.โ€‰.to obtain foreign intelligence information .โ€‰.โ€‰.or to protect against international terrorism or clandestine intelligence activities."

In 2006, Congress reauthorized the law andmade it easier to get an order because of an amendment sponsored by Rep. F. James Sensenbrenner (R-Wis.) that said any contact with a foreign agent was grounds for obtaining records. That was the year that a FISA court order began enabling the NSA to request "all call detail records" from phone companies such as Verizon. Congress was briefed on that program then and over the years. The law was reauthorized in 2011. As in previous years, efforts to limit its scope failed.

Some members now think the issue should be reexamined.

"I believe we ought to revisit that section of the Patriot Act," Connolly said.