Humphrey Errington, 72, was locked in a legal battle with South Lanarkshire Council after it called for his products to be declared unfit for consumption and destroyed.
Errington Cheese Ltd had been linked to an outbreak of E.coli 0157 in which a young girl died two years ago.
A range of Errington products is made from unpasteurised milk on their farm in Lanarkshire and environmental workers seized batches of Lanark Blue and Corra Linn as a result of the outbreak.
A civil case at Hamilton Sheriff Court heard the council claim tests revealed bacteria in both cheeses and ask for them to be labelled unsafe to eat under food safety laws.
Mr Errington said the council was wrong and branded the decision unfair.
Sheriff Robert Weir has now ruled Errington did not breach safety standards and refused to agree with the council’s request to condemn all the seized cheese.
However, he said one batch of Lanark Blue and three Corra Linn should be destroyed.
In a 255-page judgment, he said: “In my opinion, even on a precautionary approach to the pathogenicity of the strains isolated from Corra Linn, no justification has been established for condemning all 83 batches of Lanark Blue Remainder. Putting it another way, I am satisfied that Lanark Blue Remainder was ‘produced, processed or distributed’ in compliance with the hygiene regulations.
“In my opinion, the evidence establishes that the respondents did not accept raw milk for the production of Lanark Blue Remainder which might reasonably be expected to contain pathogenic organisms to such an extent that, even after the normal processing procedures had been applied, the resulting batches would have been unfit for human consumption.
“That is sufficient to deal with the application on its merits. However, for completeness, I would agree that an order for destruction of the batches of Lanark Blue Remainder would represent a disproportionate response to what the test results disclose about the respondents’ processes and products.”
He added: “For the same reasons, I do not consider that the evidence justifies such an order in relation to Corra Linn.”
Mr Errington said he will be consulting his lawyers on the firm’s next steps.