"No, I loved the job for its potential to make this country I love fairer, more tolerant, more green, more democratic, more prosperous and more just - truly a greater Britain.
"In the face of many... challenges up to and including the global financial meltdown, I have always tried to serve, to do my best in the interests of Britain, its values and its people."
Anticipating Mr Cameron's appointment, Mr Brown said: "I wish the next prime minister well as he makes the important choices for the future."
His two young sons joined him and wife Sarah for his brief statement which ended with the words: "Thank you and goodbye."
After leaving the Palace, Mr Brown returned to Labour headquarters to thank party staff. He told them that the election defeat was "his fault and his fault alone".
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.
Mr Brown paid tribute to his wife's "unwavering support"
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 and also spoke to former prime minister Tony Blair by phone.
Deputy Labour leader Harriet Harman is to become Labour leader until a replacement is elected.
Mr Brown said he would stand by the new leader "loyally and without equivocation".
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.
Mr Brown succeeded Tony Blair as prime minister in June 2007 after spending ten years as chancellor of the exchequer.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.