A federal judge approved a deal Tuesday to replace water lines at 18,000 homes in Flint, Michigan, marking a permanent fix to overcome the disastrous decision in 2014 to draw water from a river without treating it to prevent lead contamination.

Flint will be responsible for replacing lead and galvanized-steel lines that bring water into homes. The cost could be as high as $97 million with federal and state governments roughly splitting the bill. Pipes at more than 700 homes have been replaced so far.

FLINT WATER HAS FALLEN BELOW FEDERAL LEAD LIMIT

Marc Edwards, an expert at Virginia Tech who in 2015 warned about dangerous lead levels after Gov. Rick Snyder's administration repeatedly dismissed the concerns, said the agreement is a good deal for residents.

Edwards told The Associated Press that with improved water quality, temporary use of filters and new pipes, "Flint residents really have nothing to worry about other than the lost trust and history of this disaster, which may take a generation to repair."

The Natural Resources Defense Council and American Civil Liberties Union of Michigan sued the city and the state in 2016, on behalf of Flint's roughly 100,000 residents. U.S. District Judge David Lawson approved the settlement Tuesday.

Flint's water was tainted with lead for at least 18 months, starting in spring 2014. The city, under the control of state-appointed financial managers, tapped the Flint River while a new pipeline was being built to Lake Huron, but the water wasn't treated to reduce corrosion. As a result, lead leached from old pipes and fixtures.

Pipes serving 18,000 homes will be replaced by January 2020. The state of Michigan will continue to provide water filters. The agreement also allows the state to start closing free bottled water sites in Flint, depending on demand and results of water quality tests.