The Senate easily approved legislation to overhaul government eavesdropping rules in terrorism and espionage cases and effectively granted immunity to telecommunications companies that participated in a secret domestic spying program, ending a contentious debate that has raged for more than two years.

Among the 69 senators who voted "yes" on final passage was Barack Obama (Ill.), who had opposed the immunity provision in earlier versions of the wiretapping bill, a rewrite of the 1978 Foreign Intelligence Surveillance Act. The presumptive Democratic presidential nominee said revisions had alleviated his concerns, but Sen. John McCain's campaign -- and many on the left -- seized on the reversal as a flip-flop of the first order.

"He's willing to change positions, break campaign commitments and undermine his own words in his quest for higher office," said Tucker Bounds, a spokesman for the Arizona Republican.

"Senator Obama has said before that the compromise bill is not perfect," his campaign said in a statement. "Given the choice between voting for an improved yet imperfect bill, and losing important surveillance tools, Senator Obama chose to support the FISA compromise."

The bill addresses a broad scope of surveillance activities in the aftermath of the Sept. 11 attacks. In certain cases, it limits the government's ability to collect information, but it also provides greater flexibility, an attempt to reflect the changing nature of national security threats in the post-Cold War era.

The new FISA bill clarifies the scope of government intelligence activities, depending on the type and origin of the communication, and provides greater latitude to use technology to track foreign terrorism suspects overseas. The new version continues to require warrants to target Americans in the United States, but no permission is needed to track foreign citizens who are located abroad -- regardless of whether the surveillance passes through U.S-based communication networks. If the overseas target is a U.S. citizen, a warrant would be required -- regardless of where and how the spying takes place.

Although the bill increases judicial and congressional oversight, critics say that law-abiding Americans may be unfairly targeted by the wide-open foreign surveillance provisions. Sen. Christopher S. Bond (Mo.), a leading Republican supporter, countered that the risk was overblown, "unless you have al-Qaeda on your speed dial."

The final FISA revision was crafted after four months of intense negotiations between White House aides and congressional leaders. The administration threatened to veto the bill unless it retroactively protected companies including AT&T, Sprint Nextel and Verizon Communications from civil liabilities, but President Bush said yesterday that he is satisfied with the bill and that he will sign it.

"Today the United States Congress passed a vital piece of legislation that will make it easier for this administration and future administrations to protect the American people," he said.

Opponents of the measure, including Judiciary Chairman Patrick J. Leahy (D-Vt.) and Sen. Christopher J. Dodd (D-Conn.), argued that a legal exemption is at best premature, because details of the wiretapping program are not yet fully known. But a Dodd amendment that would have stripped out the immunity title received 32 votes, all of them from Democrats, including Obama, except for one from Sen. Bernard Sanders (I-Vt.).