Developers secured consent for the building of a 103-turbine scheme on Shetland known as the Viking Wind Farm in the face of objections. Campaign group Sustainable Shetland challenged the Scottish Ministers' decision to approve in a judicial review at the Court of Session in Edinburgh.
Part of their challenge claimed ministers had failed to take proper account of its obligations over the wading bird, the whimbrel, under European wild bird law.
Lady Clark of Calton said in a lengthy judgement issued yesterday: "I am not satisfied that the respondents (the ministers) have complied with their obligations under the Wild Birds Directive 2009."
The Scottish Government said in its decision letter it had careful regard to potential impact on the environment, especially wild birds.
The judge said the primary position of the ministers and the developers, Viking Energy Partnership, was that in light of conclusions of fact made by the Scottish Government the Directive was irrelevant in the present case.