Gordon Brown has announced he is resigning as UK prime minister.
Mr Brown is on his way to officially tender his resignation to the Queen, and recommend that Conservative leader David Cameron should succeed him.
Speaking alongside his wife Sarah outside No 10 Downing Street, he said the job had been "a privilege" and wished his successor well.
His decision comes as the Tories and Liberal Democrats are poised to agree a deal to form a government.
Labour's attempts to negotiate a deal of their own with the Lib Dems, after last week's inconclusive election result, ended in failure on Tuesday.
Mr Brown succeeded Tony Blair as prime minister in June 2007 after spending ten years as chancellor of the exchequer.
In an emotional farewell speech outside No 10, Mr Brown said he had "loved the job" and it had been "a privilege to serve".
"I wish the next prime minister well as he makes the important choices for the future," he said.
His two young sons joined him and wife Sarah for his brief statement which ended with the words: "Thank you and goodbye."
His resignation follows Thursday's general election in which no party won an overall majority but the Conservatives won the most seats and votes.
Both Labour and the Tories have since been trying to persuade the Lib Dems to join them in a coalition government to run the country.
Mr Brown had previously said he would resign as Labour leader, but stay on as prime minister until September, if Labour could agree a deal with the Lib Dems.
But after this possibility ended, the BBC's Political Editor Nick Robinson said Mr Brown decided he could not form a government and should stand down.
Before making his announcement, Mr Brown consulted with his wife Sarah and close colleagues including Lord Mandelson, Douglas Alexander, Ed Balls and Ed Miliband.
Mr Brown also spoke to former prime minister Tony Blair by phone.
Labour's ruling National Executive Committee has indicated it wants Mr Brown's successor as leader to be chosen as soon as possible, possibly by the end of July.