Under his leadership, Scottish Labour had suffered their worst defeat in 80 years as they were crushed by the SNP in the May 2011 Holyrood election.

An extraordinarily inept campaign had seen Labour go from overwhelming favourites to resounding losers in a matter of a few short weeks.

Labour morale was ­devastated, Alex Salmond triumphant and the East Lothian MSP humiliated.

Now Gray has made a remarkable comeback by returning to Labour’s front bench as shadow finance spokesman.

Gray, 56, admits the 2011 ­election shambles was extremely bruising – both for him and his family.

“It was 24/7 for a good three or four years so I didn’t give my family as much time as I should have,” he said.

“I ­underwent a fair bit of criticism in some sections of the media and they found that hurtful to look at.

Iain Gray is ambushed by Citizens Against Cuts during the 2011 Scottish Election (Photo: Michael McGurk)

“There’s been a lot of coverage in recent weeks of online abuse and there was a fair bit of that went on as well, and that is very hurtful for your family.”

Understandably, Gray took the lion’s share of the blame for the result.

Faced with a choice between him and the charismatic Salmond for First Minister, the public had made their feelings brutally clear.

For many, Gray’s shortcomings were summed up when he was caught on film seeking refuge from protesters in a Subway sandwich shop.

He believes the importance of that infamous incident has been overplayed but admits his leadership was a failure.

“Obviously it was a very bad night for us and when I look back on it I can see lots of reasons why we did poorly and things that we should have done differently,” he said.

“But at the heart of it I have to accept that I hadn’t performed well against Alex and we got a very bad result out of that. I have to take responsibility for that because that is what leadership is.”

Gray resigned the day after the election and has remained largely out of the spotlight since.

For the last couple of years he has enjoyed more time with his wife Gil, his elderly mum and dad and his grandchildren.

But the period in the background led to a re-evaluation of his talents and reminded many why he was leader in the first place.

Holyrood observers have been impressed by his bright contributions from the backbenches and his excellent job chairing the Public Audit Committee.

Gray has always been a talented, focused and passionate politician.

Very engaging in the flesh and full of ­interesting anecdotes about his time working in Mozambique and for Oxfam, it is a pity the public didn’t get to know him better during his time as leader.

He may have lacked Salmond’s charisma but he has always been a decent, sincere and hard-working man with a firm grasp of policy and keen eye for detail.

So it was no surprise when his successor as leader, Johann Lamont, recently called him to the frontline.

Given the torments of 2011, it was more surprising that he so readily accepted the finance brief. Was he not reluctant to venture above the parapet once again?

“No, I can’t say I was,” he laughed.

“I did think about it and think about the things I have been doing and would have to give up.

“But I have always liked to be at the centre of things, even if not actually as leader, and so I was really delighted that Johann asked me if I would come back into the shadow cabinet.

“I talked it through with my wife and she agreed it was a job I could do and I should do. I have a supportive family and they are very proud of what I’ve done and what I do.”

The Iain Gray of today seems miles away from the haunted figure of 2011.

He looks refreshed, wiser and hungry to once again take the fight to the SNP.

And his new post makes him the focus of one of the most intriguing battles in Scottish politics for some time – Gray versus Swinney.

The SNP Finance Secretary also has a period of failed leadership on his CV and Gray has not been slow to spot the parallels. He said: “I hesitate to say I look to John as a role model but he is an example of life after ­leadership.

“John was leader of the SNP who resigned after a bad election result then reinvented him as finance minister in the first SNP Government.

“Although he is my opponent I have enormous respect for John.

“He has built a reputation for economic credibility and being able to manage the budget in a way which allows him and the SNP Government to deliver on a lot of things you would say were quite ­difficult.”

This lofty talk of respect is sure to disappear when Holyrood returns from summer recess next month and debate intensifies over the independence ­referendum on September 18, 2014.

Gray believes the referendum could be Swinney’s undoing. “I’ve got a lot of respect for John but I also kind of feel sorry for him in the ­position he is in now,” he said.

“I think the referendum debate and the position the SNP have taken in it is starting to endanger John’s credibility.

“He is being forced into saying some wild and ridiculous things.”

This year a leaked document showed Swinney had privately warned colleagues an independent Scotland would struggle to fund pensions and maintain public services.

Gray said: “That is what Honest John said to his cabinet colleagues. But if we look into what he is being forced to say in public to support the case for ­independence, it is a John Swinney who promises a pension bonanza after ­independence.

“So I think the referendum debate – and maybe his colleagues – are forcing him to say things I can’t believe he really believes are true.

“They seem to have been contradicted by what he has said in private.”

Crucial votes will hinge on who wins the debate over Scotland’s future finances.

Gray can also barely contain his relish at the thought of taking on old nemesis Salmond.

Many believe the First Minister is starting to slip up, after blunders on EU legal advice and ­controversy over his behaviour during the Wimbledon tennis final.

Gray said with a smile: “One of the newspapers that backed the SNP in 2011 said one of the reasons they had supported them was because they thought Alex Salmond would better represent ­Scotland in major sporting events.

“And you know what? They might have been right about that.

“Because if I had been First Minister I wouldn’t have spent £500,000 going to the Ryder Cup in America and I wouldn’t have been waving the Saltire in the Royal Box at Wimbledon to distract attention away from Andy Murray.

“I think some of these aspects of Alex’s character and his approach to politics are becoming clearer now.”