Lady Clark of Calton yesterday set aside the consent granted to the 103-turbine development by Scottish ministers in April last year, following a judicial review brought by campaign group Sustainable Shetland.
Lady Clark held that the decision to allow the 370 Viking megawatt wind farm to be built was "incompetent" because the Viking Energy Partnership did not have an electricity generating licence.
She also said ministers failed to take proper regard of the European Wild Birds Directive, relating specifically to whimbrel, a rare species of wader with 295 breeding pairs in Shetland who form 95 per cent of the UK population.
The court also ordered Scottish ministers to pay £60,000 of Sustainable Shetland's legal expenses.
The Scottish Government said it would appeal against the judgement.
This is the first time that a judicial review of a wind farm development in Scotland has been upheld.
Sustainable Shetland chairman Frank Hay said the group was "heartened" by the outcome.
Viking Energy issued a statement saying they would not comment until the detail of the legal judgment had been issued.