The 16,000 square-metre facility, which would service a herd of 1,000 dairy cows, is proposed for a site at Lower Leighton Farm, Leighton, Welshpool.
Its backers claim the scheme would bring substantial investment as well as substantial employment benefits to the rural area.
However, it would be visible from Offa’s Dyke, a scheduled ancient monument, as well as being close to Grade I listed Powis Castle and other important heritage assets.
Potential pollution, animal welfare and human health issues were also cited by objectors.
Following a public inquiry, a planning inspector recommended refusal of planning consent for the project, principally on the basis that it would cause "considerable harm" to the landscape and the setting of heritage assets.
However, the inspector was overruled by the Welsh ministers, who concluded that the economic advantages of the scheme were compelling and that permission should be granted.
Animal welfare group the World Society for the Protection of Animals (WSPA), challenged the ministers’ decision on a number of grounds.
However, in dismissing the appeal, the court rejected arguments that the ministers had failed to pay ‘special regard’ to the impact that the development would have on heritage assets.
It accepted that ministers had given clear and unequivocal reasons and taken relevant considerations into account in deciding that priority should be given to the economic benefits of the scheme to the local community and the Welsh dairy industry in general.
The WSPA had failed to "surmount the formidable mountain" of establishing that the decision was irrational, the Court ruled.
The World Society for the Protection of Animals v The Welsh Ministers & Ors. Case Number: CO/17405/2013