Gordon Brown said he was proud of Labour’s record after 13 years in power as he delivered his victory speech in Kirkcaldy and Cowdenbeath.
He said it was his duty to play a part in Britain "having a strong, stable and principled government".
And he said he wanted that government to be able to lead Britain into "sustained recovery".
BBC political editor Nick Robinson said Mr Brown’s eyes "spoke of defeat" during his victory speech.
Labour said it was "too early to say" if they will do a deal with the Lib Dems.
Mr Brown told supporters and opponents at the count that there was no greater privilege than to serve in parliament the people he had grown up with.
"I’m proud of much that the Labour government has achieved, the minimum wage, the child tax credit, the NHS renewed, more police officers, half a million children out of poverty, two million more jobs than in 1997.
‘Sustained recovery’
"I’m proudest of all to have been returned as MP for Fife now seven elections in a row by the people who know me best, know who I am, what I stand for and what I went into politics to achieve."
In his victory speech, delivered at 0140 BST, Mr Brown said: "The outcome of this country’s vote is not yet known.
"But my duty to the country, coming out of this election, is to play my part in Britain having a strong, stable and principled government, able to lead Britain into sustained economic recovery and able to implement our commitments to far-reaching reform to our political system – upon which there is a growing consensus in our country."
Mr Brown said he entered parliament to fight for jobs, improve schools, fight discrimination and renew the NHS.
Mr Brown said he was "deeply honoured" to have been re-elected and pledged: "I will not let you down."
This article is from the BBC News website. © British Broadcasting Corporation, The BBC is not responsible for the content of external internet sites.