BALTIMORE — A federal judge has approved a $1.6 billion plan to repair Baltimore’s aged sewer system and stop wastewater from leaking into the Inner Harbor.

The consent agreement with the Environmental Protection Agency comes after years of negotiations between the city and regulators who are concerned about the environment and health impacts of sewage contamination. It replaces an agreement the city reached with the EPA in 2002, but then failed to complete repairs and upgrades called for by the end of 2015.

U.S. District Judge J. Frederick Motz approved the new agreement Tuesday.

Baltimore residents will foot the bill for much of the work through their water bills.