A bipartisan group of Senators on Wednesday reached a deal that would provide funding to help cities like Flint, Mich., replace aging lead pipes that have contributed to public health crises in several states.

Michigan Democrats Sens. Debbie Stabenow and Gary Peters worked with Environment and Public Works Committee Chairman James M. Inhofe (R-Okla.) and a bipartisan group of at least seven other senators to secure the agreement after weeks of sometimes contentious debate over how to help Flint and other cities struggling with contaminated water supplies.

The agreement includes $70 million in credit subsidies for water infrastructure projects, $100 million for subsidized loans and grants to help states with spoiled water supplies and $50 million for public health programs.

The financing package would be offset by rescinding $250 million in loan credits for a program that was intended to help auto companies develop fuel economy technology.

Lawmakers have traded barbs in recent weeks over how to best aid Flint. Democrats pushed for a $600 million emergency aid package while accusing Republicans of failing to help residents of the low-income city after a city manager installed by Michigan’s Republican Gov. Rick Snyder switched the city’s drinking water supply from Lake Michigan to the nearby Flint River.

The water switch corroded Flint’s aging pipes, releasing lead and other toxins into the city’s water supply. Democrats have held the incident up as an example of Republican governance and budget cutting gone wrong.

The compromise bill is the first breakthrough in the politically charged fight over how to help Flint and other cities that are struggling with contaminated water. The new funding would not specifically be earmarked for Flint and would be available to any city facing similar drinking water problems.

Negotiators are pursuing two separate tracks to pass the deal. The funding package was introduced as an amendment to a major energy bill that has been working its way through the Senate but it could also be considered as an amendment to a Flint aid bill that passed the House earlier this month.

The two-track approach gives negotiators flexibility to move the bill even if the potentially troubled energy bill does not pass the House.

Last month Stabenow and Peters proposed providing $600 million in funds for Flint with two-thirds dedicated to replacing corroded pipes and the remaining money going to an organization tasked with managing the fallout from the crisis for 10 years.

Senate Majority Whip John Cornyn (R-Tex.) earlier this month called the Democrats’ original proposal a “$600 million earmark” and criticized them for requesting money without also including a plan for how it should be spent.

Aides for Cornyn did not immediately respond to a request for comment on the new bipartisan agreement.