And so farewell Alex Salmond, the longest serving political leader in modern British politics.

It is a sobering thought that Mr Salmond has been leader of the Scottish National Party for nearly a quarter of a century.

I recall doing the first interview with him after he defeated Margaret Ewing for for the national convenorship in September 1990.

Okay, he had a period in exile in Westminster at the turn of the century, but that is a hell of a long time to lead any political party, let alone one as fractious and difficult as the SNP.

Mr Salmond has been under almost constant media scrutiny, over two and a half decades with his personal life minutely examined by nosy journalists and his political opponents. Everyone said that he was a devious so and so - a dodgy character - and that he'd get found out. But no one ever did. Labour say you can't believe a word he says, but they never laid a finger on him.

When Mr Salmond took over the reins the SNP was a party still in the political wilderness. He had himself been expelled for being a republican socialist member of the '79 group less than a decade previously.

The SNP had made mistake after mistake, fist trying to bribe Scots with the crass slogan of "It's Scotland's Oil" in the 1970s. It then practically destroyed itself in 1979 after the abortive devolution referendum by bringing down the Labour government of James Callaghan and forcing an election that not only Margaret Thatcher to enter Number Ten but caused the loss of 11 of their 13 MPs.

Its most recent miscalculation had been to fail to appreciate the significance of the Scottish Constitutional Convention in 1988, the cross party campaign for a Scottish parliament which the Nationalists boycotted. Political legend has it that Salmond, by then the young publicity conscious MP for Banff and Buchan, had not been contacted when the decision was made - a claim which is disputed by Salmond's bête noir, Jim Sillars. The two never got on - until the 2014 independence referendum campaign, when the hatchet was finally buried.

Most of the traditionalists in the Scottish National Party regarded young pushy Salmond with suspicion. And they were right to do so. Almost as soon as he took power he abandoned the fundamentalist approach of 'independence nothing less" and sought to place his party in the Scottish political mainstream by supporting devolution. This had previously been regarded by nationalists like Sillars as a Labour trap - a diversion from the true path of independence.

But Salmond wasn't really interested in true paths - except those that led to political power. He started to reposition the SNP as a left of centre rival to the Labour Party and when the opportunity arose to ally with Labour's Donald Dewar after the 1997 Labour election victory in the cause of restoring the Scottish parliament, he leapt at it.

It was a strange alliance. Donald Dewar never liked dealing with Alex Salmond, and made little secret of his distaste for the nationalist leader. Nevertheless, the Labour Scottish Secretary found that he needed the support of Salmond to guarantee that the devolution referendum of 1997 would be a success. It is a mark of how much Salmond had transformed his isolationist party, that he was able to join with Dewar and the Liberal Democrat Jim Wallace in the successful referendum campaign without causing any rebellion in the SNP ranks.

But the SNP were not early beneficiaries of devolution. In the 1999 Scottish parliamentary elections, the SNP were marginalised and given very rough treatment by the predominantly Labour-supporting Scottish press. Worse, Salmond discovered that while he had been a very successful debater in the House of Commons as MP for Banff and Buchan, he found that he was unable to shine in the lesser surroundings of Holyrood.

In 2000, he resigned as leader and returned to Westminster as an ordinary MP. It was a remarkable move in many ways. Here was a politician who had worked tirelessly to restore the Scottish parliament after nearly three hundred years, yet he found he couldn't function in it. At least not in the way to which he was accustomed.

However, while he was initially relieved to be free of the burdens of leadership, he soon became restless in obscurity. And when his party called in 2004, he accepted but only after his main rival, Nicola Sturgeon had withdrawn to become his deputy. She is the natural successor now that Salmond has stood down for the second and last time.

But why did he make this move now? Most people in the SNP expected him to stay on to see Scotland into the post-referendum era and resign after the next UK general election in May 2015. But Salmond likes to choose his moment. And he wanted to go out, if not on a high, then at least with his head held high. And by persuading 1.6 million Scots to vote for Yes, he had certainly made an indelible mark on Scottish civil society.

Only six months ago, few would have thought it possible to persuade 45% of the Scottish electorate to support independence. The Yes campaign also delivered the highest turnout in modern electoral history - 85%.

Within hours of his capitulation speech at Edinburgh's Dynamic Earth on Friday morning, Salmond realised that Scotland had entered a new political world one as he put it "redolent with opportunities" for the nationalist movement.

But he was astute enough to realise that his time had finally come. Had he remained any longer he would have started to overstay his welcome with an electorate that had shown remarkable tolerance for Salmond.

Even though he has lost the referendum, Alex Salmond is still by far the most popular party leader in Scotland. And that is after seven long years in Bute House. .

Salmond is a gambler. And the best gamblers know to quit when they are ahead. Nevertheless, I suspect we haven't seen the back of him quite yet, even though he will not try to make it three times lucky.