WASHINGTON (AP) — The Senate voted Tuesday to shield from lawsuits telecommunications companies that helped the government eavesdrop on their customers without court permission after the Sept. 11 terrorist attacks.

After nearly two months of stops and starts, the Senate rejected by a vote of 31 to 67 a move to strip away a grant of retroactive legal immunity for the companies.

President Bush has promised to veto any new surveillance bill that does not protect the companies that helped the government in its warrantless wiretapping program, arguing that it is essential if the private sector is to give the government the help it needs.

About 40 lawsuits have been filed against telecom companies by people alleging violations of wiretapping and privacy laws.

The Senate also rejected two amendments that sought to water down the immunity provision.

One, co-sponsored by Republican Arlen Specter of Pennsylvania and Democrat Sheldon Whitehouse of Rhode Island, would have substituted the government for the telecoms in lawsuits, allowing the court cases to go forward but shifting the cost and burden of defending the program.

The other, pushed by California Democrat Dianne Feinstein, would have given a secret court that oversees government surveillance inside the United States the power to dismiss lawsuits if it found that the companies acted in good faith and on the request of the president or attorney general.

Full telecom immunity must still be approved by the House; its version of the surveillance bill does not provide immunity.

At issue is the government's post-9/11 Terrorist Surveillance Program, which circumvented a secret court created 30 years ago to oversee such activities. The court was part of the 1978 Foreign Intelligence Surveillance Act, a law written in response to government abuse of its surveillance authority against Americans.

The surveillance law has been updated repeatedly since then, most recently last summer. Congress hastily adopted a FISA modification in August in the face of dire warnings from the White House that changes in telecommunications technology and FISA court rulings were dangerously constraining the government's ability to intercept terrorist communications.

Shortly after its passage, privacy and civil liberties groups said the new law gave the government unprecedented authority to spy on Americans, particularly those who communicate with foreigners.

That law expires Feb. 15, the deadline against which the Senate is now racing to pass a new bill.

In a separate voice vote Tuesday, the Senate expanded the power of the court to oversee government eavesdropping on Americans. The amendment would give the Foreign Intelligence Surveillance Court the authority to monitor whether the government is complying with procedures designed to protect the privacy of innocent Americans whose telephone or computer communications are captured during surveillance of a foreign target.

The bill would also require FISA court orders to eavesdrop on Americans who are overseas. Under current law, the government can wiretap or search the possessions of anyone outside the United States_even a soldier serving overseas_ without court permission if it believes the person may be a foreign agent.

"You don't lose your rights when you leave American soil," Sen. Ron Wyden, D-Ore., said in an interview. Wyden wrote the provision into the bill when it was still being considered by the Senate Intelligence Committee. "In the digital age, an American's rights shouldn't depend on their physical geography."

The House approved its own update last fall. If the Senate passes its bill, differences between the two versions remain to be worked out, approved by both houses, and delivered to the president for his signature.