A firm which admitted discharging 120 million litres of raw sewage into the Firth of Forth has been fined £13,500.
Sepa officials took water samples at Portobello Beach at the time
Veolia Water Outsourcing, then known as Thames Water Services, made the unauthorised discharge at Seafield Wastewater Treatment Plant in Leith.
The incident happened in April last year after a pump failure.
The sewage spilled into the Forth for 64 hours as engineers tried to fix the machinery. Sentence was passed at Edinburgh Sheriff Court.
The Reading-based firm admitted causing the sewage to be discharged into the Firth of Forth without authority.
The accident caused a "foul smell" in the Seafield and Leith area of Edinburgh and Scottish Water was flooded with complaints from residents concerned about the water quality.
Tests carried out days later found that the water met European standards for bathing.
Sheriff Janys Scott insisted that the offence did not merit the maximum fine of £40,000 because it had not impacted on the environment and efforts were made to correct the mistake.
But she did criticise the company for failing to have a contingency plan for both the pumps failing.
Parents kept their children off the sand at Portobello
Sheriff Scott said: "There was a potential effect on public health and there are grave public concerns for sewage treatment.
"This caused considerable anxiety."
The discharge began on the evening of 20 April last year when a pump failed at the Marine Esplanade Pumping Station.
The court heard that Veolia acted promptly to deal with the equipment failure and had since taken steps to avoid a repeat.
Tom Stalker, acting for Veolia, said: "There have been lessons learned from this.
"In hindsight, everyone wishes this hadn't happened but remedial steps have been put in place."
Colin Bayes, Scottish Environment Protection Agency (Sepa) director of environmental protection and improvement, said: "This was clearly an avoidable incident.
"Major pumping stations pose a clear threat to the environment in the event of failure, and require preventative maintenance with major back-up facilities.
"This was not evident in this case and, under different circumstances, there was the potential to cause serious environmental damage.
"So it was fortunate that the discharge was to this part of the Forth estuary, a large body of water which allowed significant dilution to minimise harm.
"A similar spill in another location may have resulted in far more serious damage and we hope this fine acts as a reminder to all operators that the prevention of pollution is an obligation, not a luxury."
At the time, Thames Water Services controlled and operated the Marine Esplanade Pumping Station while Scottish Water operated the Albert Road Pumping Station.
Thames Water Services was sold in November 2007 and its name was changed to Veolia.