The Bathgate Chemical Works opened in 1851, perhaps the first facility in the world processing mineral oils on an industrial scale.

And it was successful, highly successful, managing to compete against cheaper imported petroleum until it ceased operation in 1962, the same year the late Billy Wolfe fought the West Lothian by-election on behalf of the SNP.

He won nearly 10,000 votes and more than 23 per cent of the vote, a remarkable result in the context of then Tory/Labour electoral dominance and due, in part, to Wolfe’s argument that Westminster policy had destroyed Scotland’s once vibrant shale oil industry.

All of this came to mind in Scotland’s oil capital at the weekend, particularly during a lively debate about unconventional gas extraction (otherwise known as fracking): energy policy and Scottish Nationalism has been linked for more than half a century.

And, while in the past that connection has paid political dividends, not least in making the economic case for independence more credible in the 1970s, today it presents a considerable headache for a party otherwise in a sweet spot psychologically and electorally.

The quandary is this: the SNP leadership increasingly recognises the economic and political potential of a new energy revolution: not only could a successful domestic fracking industry generate significant revenue, but it could form the central plank of a rejuvenated argument for economic independence.

But the mood in the party self-evidently supports a complete ban. This is partly the SNP’s own fault, having created a rod for its own back during the referendum campaign by conflating fracking with the Tory/Unionist Westminster status quo. SNP badges with the instruction to “Frack Off!” remained prominent in Aberdeen at the weekend.

It was only during Friday morning’s fracking debate, however, that I realised quite how salient this opposition was. Delegate Ian Black’s peroration invoked the old SNP slogan “It’s Scotland’s Oil”, to which he added: “now it’s Scotland’s land, it’s Scotland’s air, it’s Scotland’s water” drawing loud and sustained applause, as did every other contribution in favour of an outright ban.

As this newspaper reported on Saturday a snap poll of delegates found 76 per cent against and only seven per cent in favour, a mood reflected beyond the SNP, another recent poll finding that six in ten Scots say they oppose fracking. Now of course public opinion can change, but margins like that illustrate what a bind the Scottish Government now finds itself in.

But Nationalists are nothing if not loyal, and when it came to a motion to “remit back” the line on fracking, discipline kicked in and the party escaped an embarrassing rebuke from the grassroots. Indeed it was revealing that the conference organisers didn’t allow a motion calling for an outright ban, for it would likely have been overwhelmingly endorsed; internal democracy – even in the SNP – has its limitations.

And Ineos, the company champing at the bit to start fracking in the Forth Valley (for which licenses have already been issued), is clearly getting impatient. Its lobbying operation at conference was undermined by the plenary debate, while from a commercial point of view the Scottish Government’s recent moratorium on offshore underground goal gasification has prompted speculation that Scotland’s loss could end up being England’s gain.

Ineos chief executive Jim Ratcliffe, already a bit of a bogeyman among Nationalists, has made a clever pitch, warning the Scottish Government not to delay a decision on the technology for too long as in his view fracking offers Scotland a “last chance” to gain economic independence, an indication that he’s aware of the dilemma faced by the SNP.

At conference there were also interesting attempts to start shifting the terms of debate in the context of a second independence referendum. Finance Secretary John Swinney finally conceded that oil price estimates had been wide of the mark, while others acknowledged that the “Yes” side lost the referendum, not because of “the Vow” (as Alex Salmond maintains) but because of an unconvincing economic argument.

Elected members, meanwhile, were busily trying to cajole the membership into a more pragmatic position. The Scottish Government’s cautious, evidence-based approach to fracking, they say, contrasts favourably with the Tories’ “gung ho” approach south of the border, while “trust” increasingly featured in platform speeches. “I trust our government to do this,” said Aberdeen South MP Callum McCaig, “and to do it correctly.” But while activists might trust the Scottish Government, they certainly don’t trust Ineos.

Writing in these pages during conference, another SNP MP, Stewart McDonald, presented himself as undecided on fracking and floated the sort of arguments I reckon the Scottish Government might end up deploying in support.

Carbon-based energy, argued McDonald, could provide “security” for Scotland’s energy supply, shifting the international balance away from “entrenched energy cartels” and towards “smaller scale producers”, freeing the country from dependence upon states like Russia and Qatar that aren’t exactly comfortable bedfellows in democratic and human rights terms. The 2012 debate over NATO, meanwhile, provided a “fantastic precedent” for an “emotive” policy issue being handled with “mutual respect”.

I remember that debate well, and it struck me at the time that no one actually made an intellectual case for membership of NATO on its own terms, rather it was presented as a political calculation: neutralising this issue, ran the leadership’s argument, would help them win the referendum. Perhaps the SNP is gearing up to sell fracking in a similar way: you might not like this, they’ll tell the grassroots, but “trust” us – it’ll help us win a second independence referendum.

The trouble is that while trust in the Scottish Government – and Nicola Sturgeon in particular – is clearly high, the mood at conference demonstrated that it’s not unqualified. Indeed the First Minister tiptoed round the issue in her keynote speech, simply observing that “we are safeguarding our environment” via a moratorium, while Calum McCaig demanded the devolution of licensing for offshore underground coal gasification.

It seems to me that a deep aversion to fracking has entered the soul of the party, becoming another “red-line” issue like opposition to Trident since the 1960s. On this issue above all others there is a fundamental clash between the dogmatic idealism of the SNP as a party of opposition and its pragmatism as a party of government. And while NATO membership was a lower-order issue, manageable and resolvable, fracking is not.

Thus the party has got itself into a position where, in a year or so, it will have little choice but to set such a high bar for what is considered “environmentally safe” in terms of fracking that the activity will effectively be banned. In that event, Ineos would make louder noises about quitting Scotland and the economic case for independence would once again rest upon a diminishing oil supply.

At the moment Nicola Sturgeon as SNP leader looks invincible, confident and unassailable, but resolving this issue could be one of the toughest issues she faces in the next Holyrood Parliament.