ALEX Salmond has bowed out as First Minister, telling MSPs he was leaving office with a "sense of optimism and confidence" about the future.

In a final Holyrood statement before stepping down, he said a country "empowered and energised" by the independence referendum wanted a stronger parliament to meet its aspirations.

"Goodbye and good luck," he told MSPs yesterday as he left his seat for the last time. The former SNP leader departed to applause from MSPs on all sides and a standing ovation from his own backbenchers and ministers.

Many of them assembled outside the main Holyrood entrace at Queensberry House to wave him off with mini-Saltires as he stepped into a government limousine that would take him to the Scotland-England football match in Glasgow, his final official engagement.

Nicola Sturgeon will be formally elected First Minister today after a vote by MSPs and will be sworn in at the Court of Session in Edinburgh tomorrow.

In contrast to the confrontational style he has brought to Holyrood since becoming First Minister in 2007, Mr Salmond relinquished the job with benign words and polite praise. He was humble, understated and statesmanlike in his final address.

Opponents who would previously have been falling over themselves to attack him acknowledged his commitment and thanked him for his years of public service.

Scotland's longest serving First Minister will remain MSP for Abderdeenshire East but he again dropped heavy hints that he will stand for Westminster in next May's general election.

Mr Salmond said: "It has been the privilege of my life to serve as First Minister these last seven-and-a-half years.

"Any parting is tinged with some sorrow but in this case it is vastly outweighed by a sense of optimism and confidence."

Stand-in Labour leader Jackie Baillie said his "considerable abilities" would be missed, before gently poking fun at his ability to combine running the country with playing a lot of golf.

Ruth Davidson, the Scottish Tory leader, said Mr Salmond's time in office was a game of two halves - a good half in which he "stood shoulder to shoulder" with the Conservatives to get his budgets through parliament and a less impressive spell after 2011 dominated by the referendum.

Willie Rennie dared to suggest Mr Salmond's pursuit of independence had been divisive and that wounds inflicted would take "many years to heal".

This heresy was too much for the ranks of SNP backbenchers. Their adulatory reveries interrupted, they booed and hissed until even the Lib Dem leader started saying nice things.

The mood might have turned ugly again when the Green Party's Patrick Harvie blurted out the words "delusional bully" but it transpired he was referring to Donald Trump. Mr Salmond's old friend Stewart Stevenson insisted he was in the mould of John F Kennedy, likening the First Minister's achievements to putting a man on the moon.

The First Minister thanked his opponents for thanking him before dashing off to pick up his scarf and settle himself in for a last official lap of the M8.

Perhaps anticipating, dreading even, such a low-key departure, Mr Salmond had a ruse up his sleeve. On a visit to Heriot-Watt University earlier in the day, he unveiled a giant rock inscribed with one of his most memorable pledges: "The rocks will melt with sun before I allow tuition fees to be imposed on Scottish students."

The lump of Clashach sandstone, chiselled by apprentice stonemasons from Historic Scotland, was decorated with a gilt sun to illustrate the point. Some will regard it as a comical combination of hubris and poor taste. For others it is sure to become a place of pilgrimage.