Councillors had rejected plans for the cowshed at Capel Coch, near Llangefni, by Eurig Jones and Owen Rowlands.
Anglesey council’s planning committee argued the building would have a negative effect on neighbouring properties.
But the Planning Inspectorate said it would have a positive impact on the local economy.
Planning officers had recommended that councillors approve a retrospective application for the dairy parlour at the Plas Llanfihangel site.
But it was thrown out at a meeting in March, and again when it was reconsidered in April.
Some councillors claimed the development had an impact on the environment, and also, as it had been built before the planning process had been completed, approval would set a “dangerous precedent”.
But the planning inspector considering the case said she did not believe the dairy buildings would impact on neighbours, and also allowed the farm to adapt to changes in the farming industry.
Anglesey council was ordered to pay the costs involved in the inspectorate’s review.
One of the farmers, Mr Jones, said the decision had been a “big relief”.