National Grid has agreed to pay $5.38 million to state and federal agencies due to claims over environmental damage caused by the Gloucester Gas Light Company. From 1854 to 1952 hazardous chemicals were released by the plant contaminating soil, groundwater, and sediment in Gloucester Harbor. The plant was in the business of transforming coal and oil into gas leaving tar, sludge, and oil as byproducts. Of the settlement $5.3 million will be used of restoration projects implemented by the U.S. Department of the Interior through the U.S. Fish and Wildlife Service; the National Oceanic and Atmospheric Administration and the Massachusetts Executive Office of Energy and Environmental Affairs, officials said.