TWO days ago, as afternoon ebbed into evening, Alex Salmond announced that he would not be standing for re-election as leader of the Scottish National Party and, as a consequence, would not be Scotland's First Minister.

If not entirely a shock it was nonetheless surprising. For the past several months, Salmond has been ubiquitous as he endeavoured to achieve what has long been his dream, namely the rebirth of Scotland as an independent nation.

Defeat in the early hours of Friday morning put an end, at least for now, to that ambition. Salmond, who is as much of a pragmatist as he is an optimist, surely felt that he had given it his best shot, and that he had done everything he could do.

The annals will show that he faced enormous pressure and a level of personal opprobrium and abuse that would have tested the mettle of many lesser individuals. Yet throughout a campaign that was draining and inspiring, energising and exhausting, he remained ebullient. Like the generals of old, he did not ask anyone to do anything he would not do himself. Salmond believed - as did many others in the Yes camp - that despite the polls, victory would be secured. He was convinced that, as they hovered over their ballot papers in the polling booths, Scots would opt to break away from the rest of the United Kingdom and run their own affairs.

That they did not was undoubtedly a terrible blow. To have spent the best part of four decades pursing those aims and to have them seized from his grasp at the last minute was hard to take. He of all people, however, will have appreciated that, in politics as in chess, it is the player who checkmates his opponent who wins the game.

The 11th-hour move by David Cameron, Nick Clegg and Ed Miliband to promise extensive new powers to the Scottish Parliament may have been the one that finally scuppered the nationalists' cause.

We can well imagine Salmond's reaction to that. He does not like to lose. Once, when he was at St Andrews University, he was runner-up in a student election. It is something he has never forgotten. At the time he stormed angrily out of the count. When this was pointed out to him, he quoted the racing driver, Jackie Stewart: "Show me a gracious loser, and I'll show you a loser."

Losing is not in Salmond's DNA. But, as he demonstrated when he let it be known he was standing aside, he has learned to show magnanimity in defeat. Inwardly, he may have been seething but outwardly he exuded statesmanship. The arguments had been made, the fight had been fought, and the people had decisively decided which side had won.

Though no knockout blow was delivered, Salmond realised that the moment has come for him to step aside. On the last day of this momentous year, he will be 60. His wife Moira is 17 years his senior and they both deserve a break.

Throughout the campaign she has been by his side, offering advice, chivvying him to get to meetings near - if not at - the appointed time, ensuring that he does not appear at official functions with a Hearts scarf draped round his neck.

Like her husband, Moira Salmond was dismayed by his performance in the first televised debate with Alistair Darling, leader of Better Together.

During that, it was apparent that the First Minister was not in his element, as he usually is when a camera is pointed in his direction. He looked tired, distracted, unfocused. Normally quick-thinking, he looked like an under-rehearsed actor who has mislaid his script.

Faced with relentless questioning on the currency issue from a finger-pointing Darling, Salmond groped for answers. And, then, when it was his turn to interrogate, he played Ernie Wise to Eric Morecambe, giving his opponent the heaven-sent opportunity to make him look a fool.

It was a bad omen and one which deflated the Yes cause. What was Salmond playing at? Who was advising him? What on earth possessed him to talk about aliens and cars driving on the other side of the road? Broadcast live on STV, the only good news was that the programme crashed moments before viewers logged on to watch it online. In the second debate, staged by BBC Scotland, Salmond had to redeem himself and, more importantly, give much-needed impetus to the Yes side which was flagging in the polls and showing signs of running out of steam.

This was a quite different Salmond. From the get-go he looked ready to deal with anything that was thrown at him. He looked slimmer, fitter, faster on his feet, a credit to the diet which he and Beyonce have been following. Darling came at him snarling and babbling, like Joe Frazier in pursuit of Muhammad Ali.

It was not a contest of equals. You could tell immediately that this was Salmond of old; comfortable in his own skin, confident of his argument, and assured that his adversary was there for the taking. For the former Chancellor of the Exchequer, it must have been an awfully long two hours.

His humiliation was complete when Salmond, by now purring like a Rolls-Royce, offered him, in the event of a Yes majority, a job with "Team Scotland". Darling's smile was that of a man who knows he's down and had better stay there lest he be given further punishment.

In the end, however, it was all to no avail. In the years ahead, the record will show that Better Together managed to convince more than two million people that the status quo was preferable to independence. Having come so close to achieving his goal, Salmond must find that hard to accept. The consolation is that 1.6 million people voted for independence.

Among the SNP, he has long been a gradualist rather than a fundamentalist. Though he is often portrayed as a risk-taker, he is also cautious. He moves forward one step at a time. First, the SNP had to be modernised. Then came devolution, followed in 2007 by the first SNP-led administration at Holyrood which had to negotiate with its rivals to pass legislation. Four years later came the remarkable victory, unforeseen by all psephologists and every political insider, which not only returned the SNP to power but gave them a majority over all the other parties and the mandate to call the referendum.

Let there be no mistake; this was Alex Salmond's doing. Now he knew the moment of truth could not be avoided. Where Gordon Brown might have hummed and hawed, Salmond leapt. No one was more aware than him that the chance was unlikely to come again in his lifetime. There was no option but to grasp it. It was a gamble he could not avoid.

There have been many such in his career. In 2007, for instance, he set himself the task of winning the Gordon seat in the north-east, which was held by the Liberal Democrats. If he could take it, then the SNP might prevail. Some, including the incumbent MSP, felt Salmond had finally bitten off more than he could chew.

Gordon was number 18 on the SNP's wish-list. He was standing for it, he told me, because it was necessary for him to lead by example, rather than take a safe seat. "I'm told it's incredibly difficult to do," he said late one night. He was nursing a dram, a smirk rather than a smile creasing his face. Then he added with utmost seriousness: "I think we'll win this seat and I think I'll win it well. At the end of the day, people will vote for an idea and a vision." He won with a majority of more than 2000.

This is not to suggest he enjoys universal popularity. On the contrary, some people, many of whom favour independence, find him unsympathetic and antipathetic. While some see his pugnaciousness as arrogance, others interpret it as archetypically Scottish. In person, he is affable, engaged, witty, feisty, occasionally peppery, always eager to offer an anecdote. Had he not been a politician he may well have become a journalist, for he has an unerring ability to sum things up in a sentence and can write headlines as others can wish-you-were-here postcards.

What cannot be gainsaid, however, is that he has been, as much as any political leader in a Western democracy, the unchallenged and acknowledged star of his bailiwick. Moreover, he has, wherever one stands on the question of independence, retained the support of the party and the public. After seven years as First Minister, opinion polls show that if there were an election tomorrow the SNP would still be in government, though not perhaps with the majority they have at present.

Of course, Salmond has resigned before. In 2000, he declared that after 10 years as leader of the SNP, he was quitting. At the time it was a decision viewed with scepticism and nourished by rumours, which he revelled in recounting. He was - he delighted in relating on the day he announced his resignation - supposed to be terminally ill or have accumulated mountainous gambling debts or be having an affair with Nicola Sturgeon.

All were the stuff of fantasy. The reality is he had always vowed to spend 10 years as leader and having done that he was going to address the problem of his golf handicap. In 2004, however, he was back and determined to make the SNP the party of government.

Who is to say that - pace Sinatra - there will not be another comeback. Already the "promises" made by Cameron, Clegg and Miliband are beginning to test the credibility of the Trades Description Act. Their pledge, like Clegg's on university tuition fees, looks increasingly suspicious and susceptible to attack from disaffected MPs on all sides of the house.

Salmond, who later this week will enjoy the respite of the Ryder Cup at Gleneagles, is not about to disappear. He will still be an MSP and, significantly, an MP.

Few know their way better around the nooks and crannies of the Palace of Westminster than he. After all, this is a man who, as a rookie, had the courage to interrupt Nigel Lawson's Budget speech. "This Budget," Salmond said from the backbenches as Winnie Ewing tried to restrain him, "is an obscenity."

In the weeks ahead, he may need to use similar language if there is any hint of Scotland being short-changed. But what can be safely said is that love him or loathe him, we have not seen the last of him.