In the waters of the North Sea a few miles off Scotland’s east coast, a nine-year battle has been raging that threatens a fragile and unique environmental equilibrium. The struggle has made mortal enemies of two huge lobbies that share a passionate commitment to the environment.

On one side are the developers of four vast windfarms comprising 335 turbines, which are planned for the waters of the Firth of Forth and the Firth of Tay. The windfarms are backed by the Scottish government, which regards renewable wind energy as key to the economic future. Pitched against them is the Royal Society for the Protection of Birds, which claims the scale of the developments threatens the existence of some of Scotland’s best-loved species of seabird.

While the developers claim that the windfarm projects could generate enough power to supply 1.4 million homes, the RSPB argues that they threaten the future of seabird colonies populated by puffins, gannets and kittiwakes. After ministers approved the four turbine developments – Inch Cape, Neart na Gaoithe, Seagreen Alpha and Seagreen Bravo – in 2014, the RSPB won what it thought was a landmark victory last year, when one of Scotland’s most senior judges, Lord Stewart, upheld its appeal.

Last week though, Scotland’s most senior judge, Lord Carloway, reversed the decision, reigniting a fierce dispute.

Speaking after Lord Carloway’s ruling, Stuart Housden, the director of RSPB Scotland, said: “We are hugely disappointed by today’s judgment. Whilst we fully support deployment of renewable energy, this must not be at any cost. Combined, these four huge projects threaten to kill thousands of Scotland’s internationally protected seabirds every year, including thousands of puffins, gannets and kittiwakes. These could be amongst the most deadly windfarms for birds anywhere in the world.”

The RSPB believes that the sheer scale of what is being proposed makes these sites potentially lethal. The presence of so many turbines will cause puffins to stop feeding around them, they say. As there are few other suitable sites for them, puffins will be starved of their natural food supply and their colonies will shrink drastically. Gannets and kittiwakes are at risk from the length of the proposed turbine blades, which will be significantly longer than in previous windfarms, says the RSPB. It notes the irony that, if the sites were being built to the latest specifications, the power required to move them would be greater and the blades thus smaller, posing less of a threat. But the new turbines will be built under old legislation that permits bigger blades to be used.

A spokesman for Red Rock Power, which is developing the Inch Cape windfarm, said it would continue to “work collaboratively” with the RSPB and other stakeholders to minimise environmental impacts.

Neart na Gaoithe’s developer, Mainstream Renewable Power, said the project would help Scotland and the UK to meet climate and energy goals, as well as create more than 500 jobs during the construction phase and more than 100 permanent jobs once the windfarm was operational.

The energy minister Paul Wheelhouse said: “The Scottish government remains strongly committed to the development of offshore wind energy, as this key low-carbon technology offers a huge economic opportunity for Scotland.

“Clearly, protecting Scotland’s marine environment is of paramount importance and at the heart of the Scottish government’s approach to offshore renewable energy applications, and we are keen to work constructively with the RSPB and renewable energy developers to ensure the sector has a bright future in Scotland.”

The RSPB is understood to be studying the judgment with a view to making a further appeal to the UK supreme court. The society has not ruled out an appeal to the European courts as its case hinged on European legislation designed to protect seabird colonies. Some conservationists say they are dismayed that the views of scientists employed by the government – no matter how questionable – are deemed to be sacrosanct.

Lord Carloway’s judgment is certain to strengthen the resolve of environmental agencies to press for the establishment of an independent environmental court or tribunal staffed by specialists in environmental law.

Scotland’s renewables industry has grown rapidly from a boutique presence into a mainstream economic player. On one day in August last year, Scottish wind turbines generated more electricity than was used across the nation on a single day, the first time this had occurred. The industry now employs more than 20,000 people and attracts a level of investment that will soon be measured in billions of pounds a year. In 2016 52.8% of Scotland’s electricity was produced by renewables – the highest proportion in the UK. Scotland also produces a third of the UK’s green energy.

Mersey feat: world's biggest wind turbines go online near Liverpool Read more

But the RSPB says such numbers must not be achieved at any cost. It points to the size of Scotland’s coastline, which is among the longest in Europe, and the huge expanse of its marine territories, which swamp its land mass. This provides plenty of alternative and less harmful sites, according to the society. The Scottish government must strike a delicate balance. While Scotland produces more than 20% of Europe’s wind energy, the country is also home to a third of the continent’s nesting seabirds. These species make a crucial contribution to Scotland’s highly lucrative tourism industry.

Protection agencies have been dismayed by some of the government’s figures contained in its impact reports. These estimate thatmore than 1,000 gannets would perish in the turbines each week, along with a similar number of puffins and hundreds of kittiwakes. One environmental source said: “It’s deeply disturbing that a government committed to the protection of its native wildlife populations thinks that these numbers are an acceptable minimum for a development such as this.”

In the end, it might all come down to the nature of Britain’s post-Brexit relationship with Europe. These bird colonies are protected under European law, which imposes stiff tests before windfarm development can be permitted near seabird habitats.

Developments cannot go ahead if there is a significant impact on birdlife or on the integrity of the sites. It stipulates that it must be shown that all other alternative sites were explored. Ultimately, it is European law that gives the RSPB hope of success.