WASHINGTON — Congressional leaders have agreed to a compromise surveillance bill that would effectively shield from civil suits the telecommunications companies that helped the government wiretap phone and computer lines after the Sept. 11 terrorist attacks without court approval.

The House was expected to pass the bill today, potentially ending a monthslong standoff about the rules for government wiretapping inside the United States.

House Majority Leader Steny Hoyer of Maryland said the bill "balances the needs of our intelligence community with Americans' civil liberties and provides critical new oversight."

The issue of legal protection for telecommunications companies that participated in warrantless wiretapping has been the largest sticking point. The Senate passed a bill that immunized them from lawsuits, but the House bill was silent on the matter.

The White House had threatened to veto any bill that did not shield the companies, which tapped lines at the behest of the president and attorney general but without permission from a special court established for that purpose, the Foreign Intelligence Surveillance Court. On Thursday, White House spokesman Tony Fratto said the bill met the standards sought by Bush.

Warrantless wiretapping went on for almost six years until it was revealed by The New York Times. Some 40 lawsuits have been filed against the companies by people and groups who think the government illegally eavesdropped on them.

The compromise bill would have a federal district court review certifications from the attorney general saying the telecommunications companies received presidential orders telling them wiretaps were needed to detect or prevent a terrorist attack. If the paperwork were in order, the judge would dismiss the lawsuit.

Rep. Roy Blunt of Missouri, the second-ranking Republican, predicted all the cases would go away.

Under the compromise, the district judge would for the first time be allowed to read the top-secret letters from Bush administration officials — usually the attorney general — to the companies requesting domestic wiretaps without court orders, according to Democratic aides. Each company got around 40 such letters, they said, speaking on condition of anonymity because of the sensitivity of the matter.

The compromise bill would also require the inspectors general of the Justice Department, Pentagon and intelligence agencies to investigate the wiretapping program to determine both its scope and legality. The report is due in a year.

Those two provisions, immunity and investigation, are meant to balance two competing concerns. Advocates for telecom protection say the companies acted in good faith and that the wiretaps were necessary to avert another terrorist attack. Opponents to immunity say civil lawsuits are the best way to determine whether the Bush administration illegally spied on Americans.

Not all Democrats were falling in line with the compromise. Senate Majority Leader Harry Reid of Nevada and Sens. Patrick Leahy of Vermont, Chris Dodd of Connecticut and Russ Feingold of Wisconsin said they opposed immunity. Feingold called the bill a "capitulation."

"The House and Senate should not be taking up this bill, which effectively guarantees immunity for telecom companies alleged to have participated in the president's illegal program, and which fails to protect the privacy of law-abiding Americans at home," Feingold said.

Several privacy and civil rights said Thursday they opposed the bill. The liberal political activist group MoveOn.org was organizing a phone campaign Thursday to pressure House members to defeat it.

Sixty-eight senators were expected to support the compromise, enough to defeat any filibuster attempt. The previous Senate bill, which gave the companies blanket immunity, passed with 67 votes. Sen. Dianne Feinstein, a California Democrat, was expected to join that group because the new bill includes a measure she championed— making FISA the only legal authority for wiretapping for intelligence purposes.

Rep. Peter Hoekstra of Michigan, the senior Republican on the House Intelligence Committee, said passage of the bill by Congress was necessary before August when the first yearlong surveillance orders approved under a previous surveillance regime would run out.

The Foreign Intelligence Surveillance Amendment bill also would:

—Require FISA court permission to wiretap Americans who are overseas.

—Prohibit targeting a foreigner to secretly eavesdrop on an American's calls or e-mails without court approval.

—Allow the FISA court 30 days to review existing but expiring surveillance orders before renewing them.

—Allow eavesdropping in emergencies without court approval, provided the government files required papers within a week.

—Prohibit the government from invoking war powers or other authorities to superseding surveillance rules in the future.

The new FISA bill, if it became law, would expire in 2012.