Hygiene inspectors found "a serious and established mouse infestation" at Dairy Crest's distribution depot and store at Fenstanton, heard Huntingdon magistrates court.
Inspectors visiting the depot discovered cheese and milk that had been knawed or had droppings on them. Carrier bags containing customers' groceries had been put in cages at high levels to stop the mice reaching them.
Vicki Stevens, prosecuting for Huntingdonshire District Council, said the depot's drainage gullies had been blocked with "foul smelling sludge and debris including bottled tops and cigarette ends".
The court fined Dairy Crest, one of the UK's biggest dairy processors, £17,000 and ordered it to pay £4,000 legal costs to the council.
It said magistrates had considered sending the case to the Crown Court because of the "long period of time when things were not right".
The firm pleaded guilty to the charge that food in the depot would likely be unfit for human consumption because it had not been not stored to protect it from contamination.
The group also pleaded guilty to three other breaches of food hygiene legislation: not keeping the premises in good repair, inadequate drainage facilities, having a depot layout that did not permit good hygiene practices.
Local authorities were alerted to a problem at the Fenstanton depot after a consumer complained of mouse droppings on the side of a milk bottle that had been delivered.
Stevens, prosecuting, told the court that Dairy Crest, for its part, had moved swiftly to sort the problem once hygiene authorities became involved.
The group voluntarily agreed to close the depot until work had been done. And, by the second day inspectors visited, Dairy Crest had already begun deep cleaning and structural repairs to make the building pest proof.
The fine is the first time, according to Dairy Crest's operations director, that the group has been prosecuted for breaking food hygiene law.
"The reason for this track record is that Dairy Crest does take hygiene and health and safety generally, extremely seriously," said Caroline Slettengren, representing the firm in court.
Services group Rentokil started an intensive mouse control programme at the depot days before the first visit by hygiene inspectors. And the group had previously warned of structural works that were required at the depot to stop mice getting in.