The House handed US President George W. Bush a victory, voting to expand the government's abilities to eavesdrop without warrants on foreign suspects whose communications pass through the US.
The 227-183 vote on Saturday, which followed the Senate's approval on Friday, sends the bill to Bush for his signature.
Late on Saturday, Bush said: "The Director of National Intelligence, Mike McConnell, has assured me that this bill gives him what he needs to continue to protect the country, and therefore I will sign this legislation as soon as it gets to my desk."
The administration said the measure is needed to speed the National Security Agency's ability to intercept telephone calls, e-mails and other communications involving foreign nationals "reasonably believed to be outside the United States."
Civil liberties groups and many Democrats said the new measures went too far, possibly enabling the government to wiretap US residents communicating with overseas parties without adequate oversight from courts or Congress.
The bill updates the Foreign Intelligence Surveillance Act (FISA). It gave the government leeway to intercept -- without warrants -- communications between foreigners that are routed through equipment in the US, provided that "foreign intelligence information" is at stake.
Although Bush has described the effort as an anti-terrorist program, the bill is not limited to terror suspects and could have wider applications, some lawmakers said.
The government has long had substantial powers to intercept purely foreign communications that do not touch US soil.
If a US resident becomes the chief target of surveillance, the government would have to obtain a warrant from the special FISA court.
Congressional Democrats won a few concessions in negotiations earlier in the week.
New wiretaps must be approved by the director of national intelligence and the attorney general, not just the attorney general.
Congress has battled with Attorney General Alberto Gonzales on several issues and some Democrats have accused him of perjury.
Also, the new law will expire in six months unless Congress renews it.
The administration wanted the changes to be permanent.
Many congressional Democrats wanted tighter restrictions on government surveillance, but yielded in the face of Bush's veto threats and the impending recess this month.
"This bill would grant the attorney general the ability to wiretap anybody, any place, any time without court review, without any checks and balances," Democratic Representative Zoe Lofgren said during the debate preceding the vote.
"I think this unwarranted, unprecedented measure would simply eviscerate the 4th Amendment" of the US Constitution, which prohibits unreasonable searches and seizures, Lofgren said.
Republicans were quick to dispute her description.
"It does nothing to tear up the Constitution," Representative Dan Lungren said.
If an American's communications are swept up in surveillance of a foreigner, he said, "we go through a process called minimization" and get rid of the records unless there is reason to suspect the American is a threat.
The Bush administration began pressing for changes to the law after a recent ruling by the FISA court.
That decision prevented intelligence services from eavesdropping without warrants on foreign suspects whose messages were being routed through US communications carriers, including Internet sites.