RALEIGH, N.C. — Duke Energy has agreed to remove millions of tons of coal ash containing toxic heavy metals from a power plant in North Carolina.

The nation’s largest electricity company announced Wednesday it would dig up three massive dumps at the Buck Steam Station near Salisbury and then recycle the ash for use in making concrete. The ash is left behind when coal is burned to generate electricity.

Duke agreed to remove the dumps to settle a federal lawsuit filed two years ago by the Southern Environmental Law Center. The Associated Press reported in 2014 that concerning levels of chemicals contained in coal ash were found in drinking-water wells in the nearby community of Dukeville.

Duke denies its dumps contaminated the wells but has been providing bottled water to the residents.