THE writing had been on the SNP wall for quite some time after the summer stramash over MP Patrick Grady and Ian Blackford’s mishandling of it.

With some Nationalist colleagues less than impressed with their Westminster leader’s “windbag” performances at PMQs and his unwavering obedience to Nicola Sturgeon’s orders, unease had been bubbling away for some time for the SNP champions of SW1.

Amid the Grady row, one party insider observed: “The mood has been unpleasant for months, years really. It's a vicious environment.”

At the start of the year the negativity wasn’t helped by Blackford’s controversial claim about the UK paying Scottish state pensions post-independence. The Westminster leader spent the following days trying to untangle himself, claiming, unconvincingly, he had been misrepresented.

And then there was the rebellion by two backbenchers, who defied the party whip and voted against a UK Government welfare bill when Nationalist MPs had, belatedly, been ordered to abstain.

This was such a surprise as total loyalty is demanded at all times. Sturgeon has a reputation for having what some of her detractors call a “Stalinist grip” on her party; nothing happens without her say-so.

Then in June the Grady row broke, casting a cloud over Blackford’s judgement. In a recording of a group meeting, he expressed “full support” for the Glasgow North MP.

However later, the sexual harassment complaint against Grady was upheld. He lost the SNP whip.

But as the negative fall-out began to cascade down, Blackford dramatically changed tack and publicly cast his colleague adrift, saying it was up to him to “reflect on his behaviour and where he goes from that”.

Worse for the Skye MP, the supreme leader was displeased. She insisted it was important “we don’t defend things that shouldn’t be defended” and made clear Blackford’s support for Grady in the absence of any for the victim was “utterly unacceptable”.

The fuse on his time as Westminster leader had been lit.

Yet, arguably, the most remarkable aspect of the Grady saga was how someone within the SNP group had secretly recorded one of its private meetings and then leaked the contents to the Press to clearly damage Blackford.

Owen Thompson, the new Chief Whip, warned colleagues of the leak’s potential legal implications, telling them such behaviour would “not be tolerated”. But this only intensified the row.

One member of the SNP’s executive committee told The Times Thompson’s email suggested the “leaked recording is of more concern than the plight of a sexual abuse victim,” and added: “It can’t be denied the SNP has become a party of zero tolerance; not of wrongdoing but of any criticism of their actions.”

Two weeks ago, rumours began to circulate that Stephen Flynn, the youthful Aberdeen South MP, was about to challenge Blackford for the group leadership at this Tuesday’s AGM.

The Westminster-Holyrood grapevine began to shake. Just before Blackford was due on BBC Question Time, Flynn announced he had “no intention of standing” to supplant his colleague. Pressure from the top, it seemed, had been successfully applied.

Later, Blackford confidently declared he was “looking forward” to leading the “SNP group out of Westminster for the last time”. But it seems it’s the group leading him out the door.

As Nationalist minds were concentrated following the Supreme Court verdict on Indyref2, fresh rumours flew that Flynn was reconsidering his bid; helped by 30 of the party’s 44 MPs apparently willing to support him.

Blackford realised the numbers were against him and so, to avoid humiliation, he jumped before being pushed.

Asked on Sky News to confirm this was the case, the Highland MP gave an intriguing response. Stressing it was a “tough decision,” Blackford said he had taken it “certainly on the basis of the FM giving this additional opportunity, that I have,” that is, to sell independence to business leaders.

But his answer gave credence to the suggestion it was in fact Sturgeon, who had called time on his leadership role at Westminster.

The FM popped up to insist Blackford’s departure as Commons group leader was “not a coup”. But it seems clear it had been forced.

Yesterday, Kirsten Oswald, the deputy leader, announced she too was standing down, saying it was “sensible” to have a completely new team “pick up the baton”.

Underlining the hostility that had increased around Blackford’s leadership, on hearing the Skye MP was standing aside from the leadership role, Joanna Cherry, whom he had sacked from the frontbench, said she was “pleased to hear” he had quit, tweeting: “It’s time for fresh leadership and tolerance of debate and diverse viewpoints.”

The Edinburgh MP added she hoped the Westminster group could choose its new leader “without outside interference”. I wonder who she could possibly be referring to.

One Flynnite noted how his colleague’s “coming back this quickly from a slap-down” from Sturgeon would not have occurred six months ago and added: “The fact this is happening shows her position has weakened.”

The Aberdeen MP, regarded as the favourite candidate to succeed Blackford, possibly even unopposed, is said to be eyeing a “clear-out” of the old guard and putting in place his supporters.

The 34-year-old Dundonian, who has only been in the Commons three years, is relatively unknown outside political circles, which could, of course, play to his advantage. If he wins, Flynn’s first public test will come at PMQs on Wednesday, where he will seek to ruffle Rishi Sunak’s feathers. If he masters the art of thinking on his feet in the Commons chamber, then he might cause the PM a problem or two.

With some SNP MPs deeply unhappy with Sturgeon’s de facto referendum strategy - those in marginal seats face an increased Labour threat - there is a risk that two centres of power could be created, leading to cross-border friction.

Not really the sort of thing a party wants with a general election approaching. But it could set a test for the party of independence: to see whether or not its leadership tolerates independence of mind.