Thames Water has been fined £20.3m for polluting the River Thames with 1.4bn litres of raw sewage in 2013 and 2014.
The fine is the largest penalty handed to a water utility for an environmental disaster.
The British utility admitted to water pollution and other offences that resulted in "the death of wildlife and distress to the public" at six sites in Oxfordshire and Buckinghamshire, the Environment Agency said.
Judge Francis Sheridan of Aylesbury Crown Court earlier warned the fine would exceed the firm's previous record payment of £1m paid in January 2016.
Judge Sheridan today called the spills "entirely foreseeable and preventable" and a "shocking and disgraceful state of affairs".
"It should not be cheaper to offend than to take appropriate precautions," he added.
Thames Water chief executive Steve Robertson said a number of key changes have been made in the company since the spills.
"These have included increasing the numbers of staff in key operational roles and investing heavily to improve reliability. As a result, our performance has significantly improved.
"We understand our huge responsibilities to the environment, have learned from these serious events, and continue to invest at the rate of around £20m a week on continually improving our service to our customers and the environment," said Robertson, who was appointed in September 2016
Read more: Thames Water's boss is stepping down
The spills occurred at sewage treatment works in Aylesbury, Didcot, Henley, Little Marlow and Arborfield, and the Littlemore sewage pumping station. Robertson said open days will be held later this year at each site so customers and stakeholders and see the improvements made.
"In addition, we will be adding £1.5m to our community investment fund, ring-fenced for projects to improve the river, its wildlife and surrounding environment at the affected locations."
Anne Brosnan, chief prosecutor for the Environment Agency said:
Thames Water was completely negligent to the environmental dangers created by the parlous state of its works. Our investigation revealed that we were dealing with a pattern of unprecedented pollution incidents which could have been avoided if Thames Water had been open and frank with the Environment Agency as required by water company industry protocol.
Thames Water has 21 days to pay the fine.