More than £100 billion was wiped off the FTSE 100 as the index fell more than 7%, while the pound also crashed 8% against the US dollar.
Flanked by wife Samantha, Mr Cameron said he had informed the Queen of his decision to remain in place for the short term, but hand over to a new Prime Minister by the time of the Conservative annual conference.
“The British people have voted to leave the European Union and their will must be respected,” said Mr Cameron. “The will of the British people is an instruction that must be delivered.”
His voice breaking, Mr Cameron said: “I love this country and I feel honoured to have served it and I will do everything I can in future to help this great country succeed.”
Mr Cameron said he accepted the decision of the electorate, which voted by 52% to 48% to quit the EU.
He said he would leave it to his successor to invoke Article 50 of the Lisbon Treaty, which kicks off the two-year process of negotiating a new trade relationship with the UK’s former partners.
“The country requires fresh leadership to take it in this direction,” said Mr Cameron. “I will do everything I can as Prime Minister to steady the ship over the coming weeks and months, but I don’t think it would be right for me to try to be the captain that steers our country to its next destination.”
His announcement will trigger a battle for the Conservative leadership – and the keys to Number 10 – likely to feature Brexit standard-bearer Boris Johnson taking on figures such as Home Secretary Theresa May, who took a low profile in the referendum campaign.
In Brussels and capitals around Europe, political leaders and officials went into emergency meetings to plan a response to the UK’s seismic decisions, which sent shockwaves around the world.
European Council president Donald Tusk said there was “no way of predicting all the political consequences of this event, especially for the UK” and called for calm.
“It is a historic moment but for sure not a moment for hysterical reactions,” he said.
Mr Cameron said he had summoned the Cabinet to meet on Monday, the day before he goes to Brussels for a summit where he will “explain the decision the British people have taken and my own decision” to leaders of the remaining 27 member states.
Announcing his resignation after six years as PM – and just 13 months after securing an absolute majority for the first time – was “not a decision I have taken lightly”, said Mr Cameron.
But he added: “I do believe it is in the national interest to have a period of stability and then the new leadership required.
“There is no need for a precise timetable today, but in my view we should aim to have a new prime minister in place by the start of the Conservative Party conference in October.”
He went on: “The negotiation with the European Union will need to begin under a new prime minister and I think it is right that this new prime minister takes the decision about when to trigger Article 50 and start the formal and legal process of leaving the EU.”
Remain supporters had to respect the people’s decision and “help to make it work”, said the PM.