After shirking its responsibility for years, Michigan has agreed to resolve an environmental crisis it created in Flint, by replacing thousands of lead pipes that have poisoned the city’s water. That’s good news, but it’s shameful that it took a lawsuit to make it happen.

Lead, which can damage the brain and other organs, began leaching from pipes in 2014 after an emergency manager appointed by Gov. Rick Snyder tried to save money by switching to the polluted Flint River as a water source without adding chemicals that would have prevented corrosion. Despite complaints by residents that the water was discolored, smelly and foul-tasting, local and state officials did nothing and then lied about the problem.

On Tuesday, in settlement of a lawsuit brought by residents and public interest groups, Michigan agreed to spend $87 million in state and federal funds to undo that damage and replace about 18,000 pipes in the next three years. The state will also provide residents with filters and bottled water — delivering it within 24 hours of a request from people who cannot leave their homes — and pay for regular water testing.

Flint’s misfortune drew attention to the widespread problem of contamination of water systems. So the agreement serves as a reminder of the importance of the environmental laws and regulations that the Trump administration and Republicans in Congress have made it their mission to eviscerate. While the Environmental Protection Agency’s response to the Flint crisis was not much better than the state’s, the president’s proposed 31 percent reduction in its budget would cripple its ability to respond aggressively to the next crisis, and his disdain for its work is unlikely to encourage vigorous oversight by regional officials.