Image copyright Getty Images

Petrochemical firm Ineos has lost its legal challenge against the Scottish government's "effective ban" on fracking.

The firm claimed that ministers had acted illegally in announcing the block in October 2017.

But the government argued that there is no ban in place as the policymaking process is still ongoing.

Lord Pentland agreed that the challenge was "unfounded" because "there is no prohibition against fracking in force".

And he agreed with Scottish government lawyers that statements from ministers referring to an "effective ban" were "mistaken and did not accurately reflect the legal position".

Ineos, which owns the Grangemouth refinery, and fellow petrochemical firm Reach launched a legal challenge seeking a judicial review after Energy Minister Paul Wheelhouse announced what he described as an "effective ban" in October 2017.

It followed a consultation exercise which showed "overwhelming opposition" to the controversial oil extraction technique.

First Minister Nicola Surgeon later told MSPs that "fracking is being banned in Scotland, end of story" and that people "should welcome the fact that fracking in Scotland is banned".

The SNP's website also stated that: "The Scottish government has put in place a ban on fracking in Scotland" - although this wording was changed shortly after the judgement was published.

James Mure QC, who was representing the government, told a Court of Session hearing earlier this year that the government had not in fact banned fracking - an argument that was described as a "staggering U-turn" by Ineos.

Mr Mure said the concept of an "effective ban" was PR "gloss" and "the language of a press statement".

Image caption The SNP's website said on Tuesday morning that the Scottish government had banned fracking

Image caption But the wording was changed shortly after the judge's ruling was published

He said ministers had announced "a preferred position", but "have not yet adopted a position" on fracking from a legal standpoint.

And he insisted the decision-making process would not end until environmental impact studies are finished in October.

In his written judgement, Lord Pentland backed the Scottish government's position that there is not currently a legally enforceable ban on fracking.

The judge said: "Whilst acknowledging that there have been a number of ministerial statements to the effect that there is an effective ban, the lord advocate, on behalf of the Scottish ministers, made it clear to the court that such statements were mistaken and did not accurately reflect the legal position.

"The stance of the Scottish government before the court is that there is no legally enforceable prohibition.

"I consider that the government's legal position is soundly based and that there is indeed no prohibition against fracking in force at the present time."

Lord Pentland added that the present position was "an emerging and unfinalised planning policy", and that there was therefore "no basis on which the court should interfere".

Analysis by Philip Sim, BBC Scotland political reporter

Image copyright Getty Images Image caption The Scottish government says the ongoing moratorium means there will be no fracking in Scotland

When is a ban not a ban? It mostly depends on who you ask.

Ask a politician, and they'll point out the simple fact that no fracking is going on in Scotland, and none is going to happen any time soon. In words most people would understand, it's banned.

But ask a lawyer to get into the technicalities of it, and you'll discover a completely different form of words.

A ban? Don't be silly. It's an "unfinalised planning policy expressing no support on the part of the Scottish government for the development or extraction of unconventional oil and gas in Scotland".

This is the difference between a good political argument, and a good legal one. Completely different standards apply to the language used in soapbox speeches and that used in the courts.

It can be somewhat uncomfortable to occupy both of these positions simultaneously; hence the hasty re-writing of the SNP website. Whether there's any political fallout as a result of the linguistic gymnastics employed remains to be seen.

But at the end of the day, the real-world impact is the same. Fracking is not taking place in Scotland, and won't be any time soon.

What has the Scottish government said?

Mr Wheelhouse welcomed the decision, saying that an ongoing moratorium - which is enforced through council planning powers - meant that "no fracking can take place in Scotland at this time".

And he said the judgement "vindicates the extensive process of research and consultation which the Scottish government has undertaken since 2015".

Mr Wheelhouse said a strategic environmental assessment and a business impact assessment were still ongoing, and that the findings would be "carefully considered".

He added: "In the meantime, a moratorium is in place which means no local authority can grant planning permission and ministers would defer any decision on any planning application that did come forward until the policymaking process is completed.

"The practical effect of the current moratorium and the policymaking process which is underway to finalise our position is that no fracking can take place in Scotland at this time."

What about Ineos?

Image copyright BBC Sport Image caption Ineos has been importing shale gas from abroad to its processing plant in Grangemouth

The company said it was "grateful to Lord Pentland for clarifying that there is no fracking ban" and that the judge had "effectively concluded that the Scottish government did not know what it was doing."

Its operations director, Tom Pickering, said: "We are sure that this will be a surprise to all those who heard the first minister and others repeatedly tell Holyrood the exact opposite.

"It is for MSPs to decide whether parliament was misled deliberately or simply through incompetence."

What other reaction has there been?

The Scottish Greens said the ruling would be a "welcome relief for communities throughout Scotland" and accused Ineos of attempting to "overturn the democratic decision made by the Scottish Parliament."

But the Scottish Conservatives claimed the Scottish government had deliberately misled business and local communities over the fracking ban.

Its energy spokesman, Alexander Burnett, said: "From the first minister down it has claimed fracking is banned - no ifs, no buts.

"But now the SNP government has succeeded in a court case on precisely the opposite argument - that there is no ban in place.

"In terms of the general public - whether people are in favour of fracking or deeply opposed to it - it is clear the SNP has taken them as fools."