JIM Murphy announced his resignation as Scottish Labour leader yesterday and took a bitter swipe at the "destructive behaviour" of his trade union nemesis Len McCluskey.

Murphy survived a no-confidence vote by his party - thanks largely to a former MI6 officer in the House of Lords - but he stunned colleagues by saying he would quit next month.

In an attack on Unite general secretary McCluskey, Murphy said the trade unionist's belief that Scottish Labour was to blame for the UK party's general election defeat was a "grotesque insult".

Murphy had gone to ground last week after Scottish Labour lost 39 of its 40 Westminster seats, including his own East Renfrewshire constituency.

The humiliation prompted major trade unions and members of Murphy's shadow cabinet to call for his head, but he insisted on staying in post.

At a meeting of the party's Scottish executive committee (SEC) yesterday, Murphy narrowly won the vote by 17-14.

He himself voted - a manoeuvre that raised eyebrows - and a row also broke out about the eligibility of another SEC member.

Under the rules, two members of the UK parliamentary Labour party get an SEC place, but with sole MP Ian Murray getting one vote there was nobody left to fill the other space.

Outgoing UK deputy leader Harriet Harman sent the party a letter saying the slot would be taken up by life peer Meta Ramsay, a former spy and Lords Chair of The Labour Friends of Israel.

She served in the diplomatic service between 1969 and 1991 and was involved in the successful operation to woo former KGB Colonel Oleg Gordievsky.

If she had voted in favour of the no-confidence motion, and Murphy had abstained, the vote would have been a tie.

Her participation was challenged at the SEC, but she was allowed to vote and backed Murphy.

At the meeting, a letter signed by 10 MSPs - around 25% of the group - was handed to the SEC which called on Murphy to quit.

The ten were: Claudia Beamish; Duncan McNeil; Elaine Smith; Margaret McCulloch; Margaret McDougall; Neil Findlay; Cara Hilton; Jayne Baxter; Rhoda Grant; and Alex Rowley.

After the vote, Murphy failed to tell fellow SEC members that he was planning to announce his resignation at a press conference.

He told journalists that he would table a radical set of internal reforms at the next SEC meeting and quit after doing so.

Murphy said "no option will be off the table" for party reform and said Scottish Labour is the "least modernised part of the UK Labour movement".

However, his angriest comments were reserved for McCluskey.

The source of the dispute between the pair is the Falkirk selection scandal, during which Unite was said to have manipulated the contest in a bid to benefit McCluskey's friend Karie Murphy.

The then MP had infuriated McCluskey by criticising Unite's role in the saga.

The outgoing leader said yesterday: "I know that, in the past few days, I have been at the centre of a campaign by the London leadership of Unite the union. They are blaming myself or the Scottish Labour party for the defeat of the UK Labour party at the general election. That is a grotesque insult to the Scottish Labour party.

"It is a grotesque insult to our thousands of volunteers from someone who pays occasional fleeting visits to our great country."

He slammed the "destructive behaviour of one high profile trade unionist", adding: "The leader of the Scottish Labour party doesn't serve at the grace of Len McCluskey. And the next leader of the UK Labour party should not be picked by Len McCluskey."

Murphy and his allies had spent the previous week trying to shore up support amongst different elements in the party.

Council leaders were contacted about signing a pledge of support for the ex-MP, and MSPs were also approached individually with a view to sounding out their loyalty.

In parallel, opposition to Murphy increased as the SEC meeting approached.

Scepticism about the leader was initially confined to trade unions and supporters of Neil Findlay MSP, who Murphy had defeated along with Sarah Boyack in December.

However, Boyack's supporters also began to peel away, first at a meeting of MSPs in Glasgow and then during the business days of Parliament.

The mood of MSPs darkened after a request for a group meeting was denied by the leader's allies.

Others were said to be incensed at comments made by Harman that the "group" of MSPs backed Murphy.

While the ten MSPs signed a letter calling for Murphy to quit, a counter letter supporting the leader was handed to the SEC by a group of ex-MPs.

A key figure at the centre of drama was deputy leader Kezia Dugdale, who was deemed to be a shoo-in if her boss quit.

Many of her supporters were urging Murphy to stay, not out of respect for him, but because they felt the timing was wrong for Dugdale to take over.

They believed it would be better if Murphy led Scottish Labour into the 2016 Holyrood election, take the hit, and hand over to Dugdale.

If Dugdale took over immediately, her allies feared she would get hammered next year and become a lame duck.

One senior party insider said the relationship between Dugdale and McTernan - Murphy's chief of staff - had "broken down completely".

McTernan had tried to link Dugdale's future to Murphy's fate as leader by arguing that a no-confidence motion in his boss was also a rejection of the deputy.