He said voters had "searched in their hearts" and the UK now had a "glorious opportunity" to pass its own laws, set its own taxes and control its own borders.
Another leading Leave campaigner, Labour's Gisela Stuart, said the UK would be a "good neighbour" when it left the EU.
The pound fell to its lowest level against the dollar since 1985 as the markets reacted to the results.
The slide halted when the Bank of England said it stood ready with £250bn of extra funding to ensure market stability. But the pound remains 8% down against the dollar, and 6% lower against the euro.
Flanked by his wife Samantha, Mr Cameron announced shortly after 08:15 BST that he had informed the Queen of his decision to remain in place for the short term and to then hand over to a new prime minister by the time of the Conservative conference in October.
He would attempt to "steady the ship" over the coming weeks and months, but that it would be for the new prime minister to carry out negotiations with the EU and invoke Article 50 of the Lisbon Treaty, which would give the UK two years to negotiate its withdrawal, he said.