The country's second biggest dairy processor, Open Country Dairy, has been fined just over $35,000 for discharging objectionable odours from its Waharoa factory in Waikato.
The company was prosecuted by Waikato Regional Council in the Hamilton District Court.
Forty-five complaints about the smell were received from local residents in October and November last year.
They complained about having to keep doors and windows shut, keeping children inside and in some cases, leaving town because of the smell.
Open Country Dairy told the council the odour, which came at the time of the spring milk flush, was a result of infrastructure failures at the factory when larger than normal volumes of waste ended up in a wastewater treatment pond.
The pond was not able to cope and it took some time to recover.
Judge Melanie Harland described the effect on residents as profound and continuous.
She said it was not a case of the company being slow to provide or upgrade equipment, but one that highlighted the need to provide a buffer for unexpected failures.