Boris Johnson has ended months of speculation by saying he will seek to become an MP again at next year's general election.
But he said it was "highly unlikely" he would one day stand to become Conservative leader, replacing David Cameron, as there was "no vacancy".
Mr Johnson also promised to serve his term as London mayor, ending in 2016.
The prime minister said it was "great news" that Mr Johnson was planning to return to Parliament.
The mayor has been linked with a number of parliamentary seats, including Uxbridge and South Ruislip, in north-west London, but he said he did not have a particular target in mind.
There has long been speculation that Mr Johnson will seek a return to Parliament so that he can mount a bid for the Conservative leadership when Mr Cameron stands down.
But he told the BBC's James Landale: "I think it's highly unlikely that that will happen because there's no vacancy. I think David Cameron has been a brilliant prime minister."
On BBC Radio 4's World at One, he added: "When David Cameron finally steps down, in 2030 or whenever, it may be that there's a vacancy, but it will probably be filled by a person who's a teenager now."
By BBC Deputy Political Editor James Landale
The hoopla surrounding Boris Johnson might obsess the political classes. But it matters because of what it tells us about the Conservative Party.
David Cameron is happy because one of the Tories' best campaigners is freed up to help him win votes at the general election.
Speculation about Mr Johnson's future will not now get in the way of this autumn's Tory conference.
Many Tory members are happy because they can now dream of being led by a politician who reaches voters that other Tories cannot.
Mr Johnson is happy because he could either stand for the leadership after the election or campaign for a harder line on Europe from the back benches.
Those who are less happy are other potential contenders hoping one day to replace Mr Cameron, who now face one more rival.
But even they are comforted by the fact that Mr Johnson has taken a massive gamble.
A mayor with a reputation for being almost above politics has today done something which traditional politicians do - namely wriggle out a previous commitment to serve his own ambition.
Either way, British politics has changed a gear today.
Confirming his intention to run for Parliament earlier, Mr Johnson told an audience at the Bloomberg headquarters in London that he had "danced around" the issue "for an awfully long time", adding: "I can't endlessly go on dodging these questions."
"So let me put it this way. I haven't got any particular seat lined up but I do think in all probability I will try to find somewhere to stand in 2015.
"It may all go wrong but I think the likelihood is I am going to have to give it a crack."
Asked if his target seat would be within the M25 or in the north of England, he said: "This is a matter for the (local Conservative) association. I am not going to presume to talk about which seat I might go for."
His announcement came at the end of a speech in which he said the UK should not be "afraid" of leaving the European Union if Mr Cameron fails to win a substantial renegotiation of the relationship with Brussels.
In March, the prime minister told the Sun newspaper he wanted Mr Johnson back in Parliament by 2015, comparing him to a "great striker you want on the pitch".
Following Mr Johnson's announcement, the prime minister, who is on holiday in Portugal, tweeted: "Great news that Boris plans to stand at next year's general election - I've always said I want my star players on the pitch."
The road back to Westminster
To run to become an MP, Boris Johnson would first need to win the nomination of a local Conservative association.
Constituencies he might be thinking about include: Uxbridge and South Ruislip, North-west Hampshire, South Cambridgeshire, Richmond Park and Louth and Horncastle. Here is a full list.
For Labour, shadow justice secretary Sadiq Khan said: "Boris Johnson's announcement reveals how weak David Cameron is and how out of touch the Tories remain."
He added: "Today has also shown Londoners that, when they need a mayor prepared to address the big challenges facing their city, Boris Johnson's priority is succeeding David Cameron rather than serving their interests."
After his re-election as mayor in 2012, Mr Johnson told the London Evening Standard he would not seek any other office until he had led "the city out of recession". He told the BBC that this task was now complete, with its economy growing rapidly.
But Labour MP Dame Tessa Jowell, who is tipped to run for the London mayoralty in 2016, said Mr Johnson had "made a choice in his interests". He had to "assure" Londoners that he would serve their needs, she said.
There is nothing in the rules to stop Mr Johnson serving out his term as mayor, which ends in May 2016, while also being an MP. His predecessor, Labour's Ken Livingstone, combined both roles for a year.
Mr Johnson, who served as MP for Henley from 2001 to 2008, was a Conservative education and culture spokesman before running for the mayoralty.
Former Government Chief Whip Andrew Mitchell told BBC Radio 4's World at One: "I think he's a remarkable politician. He reaches parts of the voting public that other people don't reach. He's a part of the Conservative DNA."