US telecommunications companies currently face about 40 lawsuits stemming from groups and individuals who think that the Bush administration illegally monitored their phone calls or emails under the programme.

However Bush praised the bill as being a vital tool "to help our intelligence professionals learn enemies' plans for new attacks".

'Mass surveillance'

Civil liberties groups and some Democratic critics say that the secret programme was illegal because it goes against the 1978 Foreign Intelligence Surveillance Act (Fisa), which requires a court order to spy on US citizens inside the US.

"What we have here is the opportunity for the government to commit mass
untargeted surveillance," Sheila Jackson Lee, a Democratic representative, said.

Republicans and Democrats had argued bitterly over the bill, with Democrats facing pressure in an election year to pass the bill or face accusations of being weak on terrorism, but at the same time expressing anger at what was seen as a more objectionable Senate version of the bill.

The compromise bill passed by the House requires a federal district court to review certifications from the attorney general, saying the telecommunications companies received presidential orders telling them wiretaps were needed to detect or prevent an attack.

If the paperwork is deemed in order,the judge would dismiss the lawsuit.

It would also require the inspectors general of the justice department, Pentagon and intelligence agencies to launch an investigation into the wiretapping programme, with a report due in a year.

Companies such as AT&T, Verizon Communications and Sprint Nextel are among those accused in lawsuits of violating US citizens' privacy rights.

However the White House had threatened to veto any surveillance bill that did not also shield the companies.