Some of the nation’s largest oil companies have agreed to pay about $423 million in cash to settle a lawsuit brought by more than a hundred public water providers, claiming water contamination from a popular gasoline additive.

The terms of the settlement were submitted for approval in the federal court for the Southern District of New York. Under the terms of the deal, the companies also agreed to pay 70 percent of the future cleanup costs over the next 30 years.

The defendants that agreed to the settlement include BP, Royal Dutch Shell, ConocoPhillips, Chevron, Marathon Oil, Valero Energy, Citgo and Sunoco. Six other companies named in the lawsuit, including Exxon Mobil, did not agree to the deal, said Scott Summy, a lawyer at Baron & Budd and a counsel for the plaintiffs.

In the lawsuit, the plaintiffs, which include 153 public water systems in New York, California and 15 other states, claimed that the additive, a chemical called methyl tertiary butyl ether, or M.T.B.E., was a defective product that led to widespread contamination of groundwater. The suit contended that the chemical was used by oil companies, even though they knew of the environmental and health risks that it posed.