The company was sentenced by Judge Peter Hobbs in the Wellington District Court today.
He imposed a fine of $300,000, which is lower than the total maximum penalty for all four charges of $500,000.
The fine was reduced due to mitigating factors including Fonterra's guilty plea, its acknowledgement of the offending and its cooperation with regulators.
But the fine also included an uplift to recognise Fonterra's significant financial resources.
Judge Hobbs said the offending followed from carelessness and a failure to follow procedures, rather than being deliberate and reckless. But the sentence should denounce the offending and take into account the harm it had caused New Zealand's reputation as a safe food exporter, he said.
New Zealand's reputation as an exporter was "shaken" by the incident, and access to foreign markets had been impacted, Judge Hobbs said.
MPI's lawyer, Simon Barr, said the first offence related to whey protein concentrate manufactured at Fonterra's Hautapu plant in February 2012.
The product had been contaminated during its manufacture, so the company was granted approval to rework the product.
However, it did so using non-standard equipment - including flexi-pipes and a seldom-used stainless steel pipe - which breached standard operating procedures and led to an increase in bacteria.
The second charge related to the export of the contaminated product, including 13.5 tonnes to Australia and 14.4 tonnes to China, between July and November of 2012.
The third charge related to Fonterra's failure to inform the recognised agency, AsureQuality, of significant concerns with the product until a week after it began investigating the problem last July.
The fourth charge related to Fonterra's failure to immediately disclose its concerns to MPI. It took 48 hours to do so, rather than the required 24 hours.
Mr Barr said New Zealand's reputation for quality, safe dairy products in key foreign markets had been damaged by the offending.
"The confidence of those markets in the effectiveness of New Zealand's overall food safety regulatory system was also shaken."
Fonterra's lawyer, Adam Ross, said it took the event extremely seriously, and had gone to great lengths to make sure it did not happen again.
"Fonterra has gone through an immense amount of work as a result of this incident."
In a statement after sentencing, Federated Farmers' dairy chairman Willy Leferink felt the fine was appropriate.
"Given the size of negative coverage relating to the non-botulism scare and the dent it put into the coop's reputation, the size of the fine is proportionate."
Fonterra is still facing civil action brought by the French company Danone, the parent company of infant formula maker Nutricia, which had to recall 67,000 cans of Karicare infant formula in New Zealand.
Fonterra has agreed to commercial settlements with seven other companies affected by the recall.
The charges
* Processing dairy product not in accordance with its risk management programme.
* Exporting dairy product that failed to meet relevant animal product standards.
* Failing to notify its verifier of significant concerns that dairy product had not been processed in accordance with its risk management programme.
* Failing to notify the director general as soon as possible that exported dairy product was not fit for intended purpose.