Bookies immediately slashed the odds of the flamboyant London mayor replacing Mr Cameron as the next Conservative leader.
But Mr Johnson would not be drawn on whether or not he had told the Prime Minister of his plans, before announcing them as he made a speech on Europe.
He did try to play down his chances of getting his party's top job, but was forced to deny he had chosen next year to return to Westminster because he thought Mr Cameron could lose next May's general election.
In the speech Mr Johnson urged the UK to be prepared to quit the European Union.
The message is expected to be popular with Tory voters flirting with the eurosceptic Ukip. But it infuriated the Tory's Coalition partners the Liberal Democrats who accused Mr Johnson of putting millions of UK jobs at risk.
The SNP also warned that the speech should set "alarm bells ringing". SNP Foreign affairs spokesman Angus Robertson said: "We now have a Tory leadership hopeful who would be ready to pull the UK out of Europe."
Mr Cameron was quick to welcome Mr Johnson's announcement, saying he always wanted to see "my star players on the pitch".
Labour's Sadiq Khan, the shadow minister for London, said the move "reveals how weak David Cameron is".
"The Tories are increasingly turning inwards, focused on leadership battles to come, with David Cameron powerless to do anything about it."