Sen. Dianne Feinstein said Thursday that she favors legal immunity for telecommunications companies that allegedly shared millions of customers' telephone and e-mail messages and records with the government, a position that could lead to the dismissal of numerous lawsuits pending in San Francisco.

In a statement at a hearing of the Senate Judiciary Committee, which is considering legislation to extend the Bush administration's electronic surveillance program, Feinstein said the companies should not be "held hostage to costly litigation in what is essentially a complaint about administration activities."

She endorsed a recent statement by Sen. Jay Rockefeller, D-W. Va., chairman of the Senate Intelligence Committee, that companies assured by top administration officials that the surveillance program was legal "should not be dragged through the courts for their help with national security."

Feinstein, D-Calif., plays a pivotal role on the Judiciary Committee, which has a 10-9 Democratic majority. If she joins committee Republicans in voting next Thursday to protect telecommunications companies from lawsuits for their roles in the surveillance program, the proposal - a top priority of President Bush - will become part of legislation that reaches the Senate floor.

The immunity measure would require judges to dismiss suits accusing companies of collaborating illegally in the surveillance program if the government declared either that a firm had not participated or that its participation was authorized. Lawyers for the companies' customers would be excluded from the hearing and the reason for the dismissal would not be made public.

After Thursday's hearing, Feinstein spokesman Scott Gerber released a statement from the senator saying the legislation was "a work in progress" and that she was "open to evaluating all suggestions for improvement."

Opponents of immunity for the telecommunications companies said they would try to persuade Feinstein to change her mind.

"Hopefully, since the case is in her own backyard, she won't want to foreclose people's opportunity to have their day in court," said Caroline Frederickson, lobbyist for the American Civil Liberties Union.

"There are compromises possible here," said Cindy Cohn, legal director of the Electronic Frontier Foundation and a lawyer for AT&T customers in a surveillance case before the Ninth U.S. Circuit Court of Appeals in San Francisco. One suggestion that Feinstein previously indicated she was considering, Cohn said, would be to allow the suits to proceed but set limits on damages against the companies.

The AT&T suit, filed in January 2006, is the lead case of nearly 40 filed around the country accusing telecommunications companies of allowing the National Security Agency to intercept customers' phone calls and e-mails and examine their records without a warrant. The suits have been transferred to a federal judge in San Francisco.

Bush acknowledged in December 2005 that he had ordered the agency after the 2001 terrorist attacks to wiretap phones and read e-mails of communications between Americans and alleged foreign terrorists without the court warrants required by a 1978 federal law. With lawsuits pending against the government and the companies, Congress authorized the surveillance program in August but did not immunize the companies for their past conduct.

The Judiciary Committee is considering immunity for the companies as part of a bill to extend the program past February. Feinstein, in her statement Thursday, said the suits are unfair to the companies, which are "unable to defend themselves in court" because the government has insisted that their activities be kept secret.

Although suits against the companies are "not the right remedy," Feinstein said, the administration should be held accountable through an audit of the surveillance program by the Justice Department's inspector general, as proposed in the Senate legislation.

Cohn disputed Feinstein's assertion that the companies could not defend themselves in the lawsuits. She said federal law allows such defendants to present secret evidence in private to the judge, a practice she said has been carried out for decades without any leaks.