You are not permitted to download, save or email this image. Visit image gallery to purchase the image.
Cameron announced the referendum would be held by the end of 2017, provided he wins the next election, and said that while Britain did not want to retreat from the world, public disillusionment with the EU was at "an all-time high".
"It is time for the British people to have their say. It is time for us to settle this question about Britain and Europe," Cameron said in a speech, adding that his Conservative party would campaign for the 2015 election on a promise to renegotiate the terms of Britain's EU membership.
"When we have negotiated that new settlement, we will give the British people a referendum with a very simple in or out choice to stay in the European Union on these new terms; or come out altogether. It will be an in-out referendum."
A referendum would mark the second time Britons have voted on the issue. In 1975, they decided by a wide margin to stay in the EU's predecessor, two years after the country had joined.
Domestically, Cameron stands on relatively firm ground. Most recent opinion polls have shown a slim majority would vote to leave the EU amid often bitter disenchantment about its influence on the British way of life. However, a poll this week showed a majority wanted to stay.
Cameron's position is fraught with uncertainty. He must come from behind to win the next election, secure support from the EU's 26 other states for a new British role, and hope those countries can persuade their voters to back the changes.
Critics say that in the long run-up to a vote, Britain would slip into a dangerous and damaging limbo that could leave the country adrift or pushed out of the EU.
The United States, a close ally, is also uneasy about the plan, believing it will dilute Britain's international clout. President Barack Obama told Cameron by phone last week that Washington valued "a strong UK in a strong European Union".
Some of Britain's European partners were also anxious and told Cameron on Wednesday his strategy reflected a selfish and ignorant attitude. However, Angela Merkel, the leader of EU paymaster Germany, was quick to say she was ready to discuss Cameron's ideas.
French Foreign Minister Laurent Fabius was less diplomatic, quipping: "If Britain wants to leave Europe we will roll out the red carpet for you," echoing Cameron, who once used the same words to invite rich Frenchmen alienated by high taxes to move to Britain.
Billed by commentators as the most important speech of Cameron's career, his referendum promise ties him firmly to an issue that has bedevilled a generation of Conservative leaders.
In the past, he has been careful to avoid bruising partisan fights over Europe, an issue that undid the last two Conservative prime ministers, John Major and Margaret Thatcher.
His speech appeared to pacify a powerful Eurosceptic wing inside his own party, but deepen rifts with the Liberal Democrats, the junior partners in his coalition. Their leader, Deputy Prime Minister Nick Clegg, said the plan would undermine a fragile economic recovery.
Sterling fell to its lowest in nearly five months against the dollar on Wednesday as Cameron was speaking.
Cameron said he would seek to claw back powers from Brussels, saying later in parliament that when it came to employment, social and environmental legislation "Europe has gone far too far".
But such a claw back - the subject of an internal audit to identify which powers he should target for repatriation - is likely to be easier said than done.
If Cameron wins the election but then fails to renegotiate Britain's membership of the EU, a 'Brexit' could loom.
Business leaders have warned that years of doubt over Britain's EU membership would damage the $2.5 trillion economy and cool the investment climate.
"Having a referendum creates more uncertainty and we don't need that," Martin Sorrell, chief executive of advertising giant WPP, told the World Economic Forum in Davos. "This is a political decision. This is not an economic decision. This isn't good news. You added another reason why people will postpone investment decisions."
Cameron has been pushed into taking such a strong position partly by the rise of the UK Independence Party, which favours complete withdrawal from the EU and has climbed to third in the opinion polls, mainly at the expense of the Conservatives.
"All he's trying to do is to kick the can down the road and to try and get UKIP off his back," said UKIP leader Nigel Farage.
Eurosceptics in Cameron's party, who have threatened to stir up trouble for the premier, were thrilled by the speech.
Conservative lawmaker Peter Bone called it "a terrific victory" that would unify 98 percent of the party. "He's the first prime minister to say he wants to bring back powers from Brussels," Bone told Reuters. "It's pretty powerful stuff".
Whether Cameron holds the referendum remains as uncertain as the Conservatives' chances of winning the election. They trail the opposition Labour party in opinion polls, and the coalition is grappling with a stagnating economy as it pushes through unpopular public spending cuts to reduce a large budget deficit.
Labour leader Ed Miliband said on Wednesday his party did not want an in/out referendum.
Cameron said he would campaign for Britain to stay in the EU "with all my heart and soul", provided he secured the reforms he wants. He made clear the EU must become less bureaucratic and focus more on trade deals. It was riskier to maintain the status quo than to change, he said.
"The biggest danger to the European Union comes not from those who advocate change, but from those who denounce new thinking as heresy," he said.
Cameron said the euro zone debt crisis was forcing the bloc to change and that Britain would fight to make sure new rules were fair to the 10 countries that don't use the common currency, of which Britain is the largest.
Democratic consent for the EU in Britain was now "wafer thin", he said. "Some people say that to point this out is irresponsible, creates uncertainty for business and puts a question mark over Britain's place in the European Union," said Cameron. "But the question mark is already there: ignoring it won't make it go away."
A YouGov opinion poll on Monday showed that more people wanted to stay in the EU than leave it, the first such result in many months. But it was unclear whether that result was a blip.
Paul Chipperfield, a 53-year-old management consultant, said he liked the strategy. "Cameron's making the right move because I don't think we've had enough debate in this country," he told Reuters. "We should be part of the EU but the EU needs to recognise that not everybody's going to jump on the same bandwagon."
Asked after the speech whether other EU countries would agree to renegotiate Britain's membership, Cameron said he was an optimist and that there was "every chance of success".
"I don't want Britain to leave the EU," he told parliament later. "I want Britain to reform the EU."
In the 1975 referendum, just over 67 percent voted to stay inside with nearly 33 percent against.