The bill, approved as lawmakers departed for a two-week break, faces a veto threat from President Bush. The margin of House approval was 213 to 197, largely along party lines.
Because of the promised veto, "this vote has no impact at all," said Republican Whip Rep. Roy Blunt of Missouri.
The president's main objection is that the bill does not protect from lawsuits the telecommunications companies that allowed the government to eavesdrop on their customers without a court's permission after the Sept. 11, 2001, terrorist attacks.
The vote sent the bill to the Senate, which has passed its own version that includes the legal immunity for telecom companies that Mr. Bush is insisting on.
Without that provision, House Republicans said, the companies won't cooperate with U.S. intelligence.
"We cannot conduct foreign surveillance without them. But if we continue to subject them to billion-dollar lawsuits, we risk losing their cooperation in the future," said Rep. Lamar Smith, R-Texas.
The government does have the power to compel telecommunications companies to cooperate with wiretaps if it gets warrants from a secret court. The government apparently did not get such warrants before initiating the post-9/11 wiretaps, which are the basis for the lawsuits.
House Intelligence Committee Chairman Silvestre Reyes, D-Texas, said the bill is meant to fix that. It would let a judge determine whether lawsuits should be dismissed, rather than having Congress make that decision.
"I believe that the nation is deeply concerned about what has gone on for the last seven years, and I want to restore some of the trust in the intelligence community," Reyes said.
About 40 lawsuits have been filed against telecommunications companies by people and organizations alleging the companies violated wiretapping and privacy laws. The lawsuits have been combined and are pending before a single federal judge in California.
The Democrats' measure would encourage the judge to review in private the secret government documents underpinning the program to decide if the companies acted lawfully.
The administration has prevented those documents from being revealed, even to a judge, by invoking the state secrets privilege. That puts the companies in a bind because they are unable to defend themselves.
Just a fraction of Congress has been granted access to the records.
Democrats argued against quashing the lawsuits without knowing in detail why the immunity is necessary. Rep. Jane Harman, D-Calif., said the government may have as many as five ongoing clandestine surveillance programs. "Congress is not fully informed, and it would be reckless to grant retroactive immunity without knowing the scope of programs out there," Harman said.
"All members of Congress should see those documents so they could see the breadth and scope" of the wiretapping program, said Rep. John Tierney, D-Mass.
The surveillance law is intended to help the government pursue suspected terrorists by making it easier to eavesdrop on international phone calls and e-mails between foreigners abroad and Americans in the U.S, and remove barriers to collecting purely foreign communications that pass through the United States for instance, foreign e-mails stored on a server.
A temporary law expired Feb. 16 before Congress was able to produce a replacement bill. Bush opposed an extension of the temporary law as a means to pressure Congress into accepting the Senate version of the surveillance legislation.
Mr. Bush and most Capitol Hill Republicans say the lawsuits are damaging national security and unfairly punish telecommunications companies for helping the government in a time of war.
"There is not one iota of evidence that the companies acted inappropriately whatsoever," said Rep. Dan Lungren, R-Calif.
Democrats say the bill protects the privacy rights of Americans by making sure the telecommunications companies - and the wiretapping program - did not violate any laws.
"We have the opportunity to serve the protection of our country ... and uphold our oath to preserve and protect the Constitution of the United States," said House Majority Leader Steny Hoyer, D-Md. "Let us take that opportunity."
The Democratic bill also would initiate a yearlong bipartisan panel modeled after the 9/11 Commission to investigate the administration's so-called warrantless wiretapping program.
Friday's vote came after House Republicans forced a rare, late-night secret session of Congress on Thursday to discuss the bill. It was the first such session of the House in a quarter century; the last one was in 1983, on U.S. support for paramilitary operations in Nicaragua. Only five closed sessions have occurred in the House since 1825.
Democratic Rep. Sheila Jackson-Lee of Texas said she didn't believe any minds were changed on the bill.
"We couldn't have gone more of an extra mile to make sure we're doing the best for national security," she said.