A hospital trust in Essex has been ordered to pay fines and costs of £350,000 for failing to ensure the safety of its patients.
Basildon Hospital admitted failing to protect patients and visitors between 2006 and 2007, after James Compton, 74, and Raymond Cackett, 54, died after contracting Legionnaires' disease. Six others were infected by the chronic legionella outbreak.
Bosses also pleaded guilty to a similar count after a patient, who was on the hospital's elderly ward, was injured after falling five metres from an unrestricted window.
Sentencing at Chelmsford Crown Court, judge David Turner said: "These are failures of very different kinds but each is in its own way serious."
He ordered the hospital - one of 14 named by NHS England medical director Professor Sir Bruce Keogh's report into abnormally high death rates - to pay a fine of £100,000 for the Legionnaires' offence and £75,000 for the fall.
The trust must also pay the prosecution's legal costs of £175,000.
The judge added: "The very phrase Legionnaires' disease is enough to strike a chord of concern for any of us staying in hospital anywhere in this country or who have elderly relatives staying in hospital.
"Managing and controlling these bacteria is a huge, costly and complicated challenge for hospitals everywhere. Their failure was not of ignorance, lack of concern or reckless disregard for safety.
"The extent of their shortcomings need to be seen against the complexity of the challenge they faced and the number of people through their doors."
Mr Compton, from Billericay, died in 2007 and Mr Cackett, 54, from South Ockendon, died in 2010 after contracting the disease at the hospital.
Six other patients - Egbert Van Nuil, Lyn Kilshaw, Roy Leech, Joyce Limbert, Francis Nutt and Verona Hughes - were infected. The court heard some of them "nearly died" from the disease.
Opening the case, prosecutor Pascal Bates said the hospital had been battling the disease - a serious lung infection caused by legionella bacteria which is common in water systems - for up to 15 years.
But despite a previous prosecution following the 2002 death of George Bate, 77, from Legionnaires', managers took insufficient steps to protect the public, the court heard.
Shower heads and thermastatic valves were not properly cleaned, the budget to chemically kill the bacteria was cut and attempts to tackle the disease by "super heating" hot pipes may have backfired by warming cold pipes, causing the bacteria to proliferate.
Mr Bates said: "This wasn't a situation where for a brief period of time the hospital followed advice from a particular consultant which later turned out to be wrong. This was a lengthy period of time during which the hospital fell short of its responsibilities and failed its patients."
Iain Daniels, mitigating, said the trust apologised for the deaths and for the injuries suffered by the elderly woman. He said lessons had been learned and steps taken to protect patients in future.
Speaking afterwards, Health and Safety Executive inspector Susan Matthews said: "Healthcare providers, like all organisations, have a legal duty to control risks by properly maintaining hot and cold water systems.
"The trust received numerous warnings from regulators and consultants brought in to give the hospital advice and support, but these were not fully heeded."
Andrea Gordon, director of operations (regions) of the Care Quality Commission, said Basildon and Thurrock University Hospitals NHS Foundation Trust's failures were not acceptable but progress had been made.
"We will continue to monitor the trust, including further unannounced inspections, and will not hesitate to take action where we find standards have fallen short of what people should be able to expect," she added.