The US House of Representatives has passed a surveillance bill that would allow lawsuits against phone companies.
The wiretap programme was begun in secret after the 9/11 attacks
President George Bush has promised to veto the bill because it does not give immunity to companies that participated in a controversial wiretap programme.
A previous act, allowing warrantless tapping of phone calls and e-mails of suspected terrorists, expired on 17 February but did not grant immunity.
Lawsuits have been filed against some of the firms which took part.
They are accused of violation of privacy.
The bill was approved by a slim margin in the Democrat-controlled House, but failed to pass by the two-thirds margin needed to avoid a presidential veto.
Several Democrats joined the Republican party in opposing the measure.
Mr Bush wants any telecommunications company that participated in his warrantless surveillance programme to receive retroactive immunity.
Mr Bush has promised to veto the Democrat-sponsored bill
The Senate has already approved a bill that grants such immunity.
The spying programme was begun after the 11 September 2001 attacks on the US (though the former head of one company Qwest has said that he was asked for information several months before then).
The row over whether to protect companies that participated has been a key factor in the inability of the House and Senate to agree on a new bill to replace the law that expired last month.
The legislation allowed government spying on foreign telephone calls and electronic correspondence without court permission.
Without immunity from prosecution, House Republicans said, telecommunications companies will not co-operate with US intelligence agencies.
"We cannot conduct foreign surveillance without them," said Texas Republican Lamar Smith.
"But if we continue to subject them to billion-dollar lawsuits, we risk losing their co-operation in the future."
Democrats accused Mr Bush and the Republicans of stirring up terrorism fears in an election year.
"It is time to reject the scare tactics of the Bush administration and enact this carefully crafted legislation," said New York Democrat Jerrold Nadler.
The House bill would allow phone companies faced with lawsuits to present their cases in a closed-door court, with judges allowed to review documents about the surveillance and its authorisation in private to decide whether the companies acted lawfully.