Former prime minister Gordon Brown has confirmed he is standing down as an MP and ruled out becoming a Labour peer.

In a speech in his Kirkcaldy constituency, the 63-year-old said he would quit parliament at the general election in May.

Mr Brown played a key role in the Scottish independence referendum campaign this year, sparking speculation that he would stand for leader of Labour in Scotland - something he quickly dismissed.

He told constituents it was time for a "new person, with new ideas" to represent them.

The Labour MP has focused on charity work and his role as United Nations special envoy for global education since his resignation as prime minister in 2010.

He said: "We are not leaving Fife. It is London that I'm leaving and for the avoidance of any doubt, I'm not going back to Westminster, not to the House of Commons after the general election and not to the House of Lords.

"It is Fife where our home is and where we will be, where our children John and Fraser, who are here tonight, are happily at school and it is from Fife where I will do the new and extended work as the United Nations special envoy on global education."

Gordon Brown has given a "huge amount in terms of public service", his successor at Number 10 said.

David Cameron said the former prime minister would "go on contributing to public life" even after he stands down as an MP.

The Prime Minister said: "Gordon has given a huge amount in terms of public service and his contribution in government and in Parliament.

"I'm sure he will go on contributing to public life after he leaves the Commons."

Mr Brown's controversial former spin doctor Damian McBride paid tribute to Mr Brown's long career as prime minister, chancellor and shadow chancellor.

"As a feat of sheer endurance, no modern politician will ever again match Gordon Brown's 18 years at the top of his party," he said.

First Minister Nicola Sturgeon said: "I wish Gordon Brown well. There is no doubt that has made an enormous contribution over many years to Scottish, UK and international politics. While we have clearly had our political differences - most recently in the independence referendum - he has my very best wishes as he announces his retirement from politics and for whatever he decides to do in future."

Former Liberal Democrat leader Sir Menzies Campbell said: "Like all politicians Gordon Brown will be remembered for a variety of reasons but no one should ever forget that when the world economy stood on the abyss it was his determined action which persuaded many countries to take the cumulative steps which ensured that there was not a global depression."

The MP for North East Fife, who will also end his Commons career at the 2015 general election, said: "As the MP for the neighbouring constituency of mine in Fife our personal relations have always been cordial and I count him as a friend.

"Whatever he does next we can be certain that he'll do so with vigour and commitment for the public good. "

Scottish Labour leadership candidate Neil Findlay MSP, who tried to convince Mr Brown to stand for the position he is currently vying for, said: "Gordon Brown has made a huge contribution to politics in Scotland and far beyond.

"His lifelong commitment to tackling poverty has guided his political life. I was delighted to speak on the same platform as him during the referendum when he joined us at Livingston football stadium to put the Labour case for remaining part of the UK - a case based on social solidarity and the redistribution of the UK's resources.

"On Saturday Gordon urged the political parties to use the new powers to take action on poverty and inequality, youth unemployment, to protect pensions, create jobs and end injustice - these are the issues that I have put at the heart of my campaign.

"I wish Gordon and his family well for the future knowing he will continue to campaign on the issues that have always concerned him. "

Scottish Conservative leader Ruth Davidson MSP said: "Gordon Brown's decision to stand down is the right one, and, following the success of the Better Together campaign, he leaves Westminster with his head held high.

"Growing up in Fife, I have seen how committed he has been to the area. Even when he lived in Downing Street, Fife was his home and everybody in the Kingdom knew it.

"I think history will judge Gordon Brown more kindly than the rough and tumble of contemporary politics, particularly his time as Chancellor.

"He championed the UK's public services and his work in Africa - both for poverty reduction and girls' schooling - has helped improve thousands of lives.

"His interventions in the closing stages of the referendum campaign showed how powerfully and directly he is able to speak to Scotland's Labour voters - something Ed Miliband seems singularly unable to manage.

"For that alone, all people who cherish the UK should be thankful.

"A big Beast is leaving the stage."

Lord Mandelson, one of the architects of New Labour along with Mr Brown and Tony Blair, said the Kirkcaldy and Cowdenbeath MP would be remembered for saving the banks and the Union.

He said Mr Brown "didn't get everything right" but he "did get the big things right".

Lord Mandelson said: "Gordon Brown was a big man when he was instrumental in creating New Labour with Tony and the rest of us and he remained a big man both as chancellor and prime minister.

"He didn't get everything right, and he would be the first to acknowledge that, but he did get the big things right - notably when it came to saving our banks after the financial crisis and saving the union when it looked as though Scotland was going to go independent.

"That's what he will be remembered for."

Unite's general secretary Len McCluskey said: "Gordon Brown exits the domestic political stage with his head held high. Decency, fairness, a man determined to take on the inequalities that blight lives - these are qualities we can forever associate with Gordon.

"He came into politics for all the right reasons - to do good, to make life better for ordinary people, and he did both. We must never forget the mess that Labour inherited in 1997 and how Gordon as chancellor set about rebuilding a nation shattered by four terms of Tory rule.

"He can be proud of his immense contribution to public life in these isles, and we in Unite are hugely proud that Gordon, a member of our union, just as he was a member of the Transport and General Workers Union before, became chancellor then prime minister.

"I would urge younger Labour MPs to learn from Gordon's journey and in doing so consider the part this great movement of ours played in his politics.

"He understands that trade unions bind the people to the Labour party in a set of shared beliefs; this matters as much today as it did when Gordon started out as a young Labour candidate more than thirty years ago.

"Gordon Brown still has so much more to contribute. We at Unite will watch on as Gordon opens this next chapter in his life and wish him, Sarah and the boys a happy and fulfilling future."