Scottish Water has been fined £6,700 after admitting polluting the River Eden in 2018.
About 400 litres of a chemical coagulant were discharged - resulting in the death of at least 500 trout and salmon.
Dundee Sheriff Court heard that an operator punctured a large chemical container with a forklift truck, while attempting to move it from storage, at Cupar waste water treatment works.
It resulted in 500 litres leaking on to the forecourt.
The operator managed to turn the container over in an attempt to prevent further spill and moved the ruptured container to an unbunded corner of the site.
An attempt was made to clean up the spill by hosing and mopping the chemical spill into nearby surface water drains - which discharge into the River Eden.
The chemical also leaked from the spill site to the rear of the works and entered the river in several locations. Additionally, the punctured container left in the unbunded area spilled further toward a water drain.
SEPA was alerted later that day when members of the public reported dead fish in the river. Officers inspected the site and identified where the chemical had entered the River Eden.
During the investigation SEPA found there was a lack of knowledge among Scottish Water employees regarding the harmful effects of the chemical and the importance of preventing it from entering the water environment.
There was also a lack of training around chemical handling. Site staff were not appropriately trained in emergency spill response and were unaware that the surface water drains on site discharged into the river.
Most of the fish killed were brown trout but there were also salmon and sea trout.
The incident had serious financial consequences for the local angling club and is likely to have an impact on salmon and trout numbers for four or five years.
The company pleaded guilty to a charge under section 20(3)(a) of the Water Environment and Water Services (Scotland) Act 2003.
Fiona Caldwell, procurator fiscal, wildlife and environment, said: "This incident was brought to the attention of SEPA by members of the public, at which point the environmental damage was already done.
"It was entirely avoidable. Scottish Water failed to provide adequate training in relation to the chemicals used, their handling or appropriate spill training.
"That failure, the resultant damage to the environment and the impact on the local community, is unacceptable.
“The Crown Office & Procurator Fiscal Service takes a rigorous approach to environmental crime and we are committed to taking effective and appropriate prosecutorial action.”