The nation’s largest electricity company has admitted to illegally polluting North Carolina waterways with toxic coal ash. Duke Energy Corp. this week pleaded guilty to nine criminal violations of the federal Clean Water Act and agreed to pay $102 million in fines and fees for environmental conservation projects.

U.S. District Court Judge Malcolm Howard said Thursday the penalty is the largest federal criminal fine in North Carolina’s history.

Four of the nine charges involved illegal discharges of coal ash at Duke’s Dan River coal-fired power plant near Eden, North Carolina. In February 2014, the facility sent 39,000 tons of the sludgy byproduct floating down 70 miles of the Dan River, which flows into Virginia. Duke also pleaded guilty to pollution violations at power plants near Charlotte, Asheville, Goldsboro and in Chatham County.

As part of the negotiated settlement, three subsidiaries of Duke agreed to pay a combined $68 million in criminal fines and to spend $34 million on environmental projects and land conservation to benefit rivers and wetlands in North Carolina and Virginia.

The decision “officially closes this chapter in our company’s history,” Duke said in a statement. “We’ve used the Dan River incident as an opportunity to set a new, industry-leading standard for the management of coal ash.”

Ash is created by burning coal for electricity and contains toxic heavy metals such as arsenic, mercury and lead. Duke, a $52 billion company in based in Charlotte, stores more than 150 million tons of the substance in 32 dumps at 14 power plants in North Carolina. All of the facilities are located near rivers and lakes that supply towns with drinking water. Even before the Dan River spill, state environmental officials found all of the utility’s unlined waste pits to be contaminating groundwater at the plants.

At the hearing Thursday, federal prosecutors told Judge Howard that Duke ignored repeated warnings from state officials and environmental groups about problems at its coal ash dumps. Prosecutors gave multiple examples of Duke failing to prevent its illegal pollution, despite adequate warnings, the Associated Press reported. In the Dan River incident, engineers at the plant in Eden twice requested $20,000 from Duke headquarters to use a robotic camera to inspect aging drainage pipes -- including the one that later collapsed and resulted in the spill.

“They should have been monitoring better, they should have been fixing what they saw, they should have been listening to their employees,” Assistant Attorney General John C. Cruden said, the AP noted. “If they had done that, the spill we saw would not have occurred.”

Federal environmental officials later scolded the utility for jeopardizing drinking water for millions of North Carolina residents. “Companies that cut corners and contaminate waters on which communities depend, as Duke did here, will be held accountable,” Cynthia Giles, an assistant administrator for the U.S. Environmental Protection Agency, said in a statement.

Duke is in the early stages of a long process to move or cap 24 coal ash dumps by 2029. Eight other dumps must be excavated and shuttered within five years, according to a North Carolina law adopted last year in response to the Dan River spill. The coal ash law also requires state investigators to test private wells within 1,000 feet of power plant boundaries. About 145 wells have been sampled since last October, and at least 87 of those show signs of groundwater contamination.

At Thursday’s hearing, Judge Howard also sentenced Duke to five years’ probation. Under the terms, the utility will be monitored for compliance with the Clean Water Act. If Duke violates the law during that period, it could be subject to further fines or penalties by the court.