Claiming that public disillusionment with the 27-nation EU is "at an all-time high," Cameron used a long-awaited speech in central London to say that the terms of Britain's membership in the bloc should be revised and the country's voters should have a say.
Cameron proposed that his Conservative Party renegotiate the U.K.'s relationship with the EU if it wins the next general election, expected in 2015.
"Once that new settlement has been negotiated, we will give the British people a referendum with a very simple in-or-out choice to stay in the EU on these new terms. Or come out altogether," Cameron said.
The speech was seen by many as a gamble to shore up support from Cameron's fractured, increasingly anti-EU party that risked antagonizing other countries focused on stemming the eurozone debt crisis.
The fiercely independent island nation has never been an enthusiastic member of the bloc, seeing itself as culturally different and balking at having policy dictated by Brussels. But the drumbeat has grown over fears that new EU regulations to address the debt crisis will further restrict the country's control over its own economic policies.
Many EU member states, which had in the run-up to the speech stressed the importance of Britain's presence in the bloc, took a sharper tone after Cameron spoke.
Martin Schulz, the president of the European Parliament, said Cameron was playing "a dangerous game," and accused him of playing domestic politics.
"This was an inward-looking speech that does not reflect European reality and will not impress many of the U.K.'s European partners," Schulz said.
French Foreign Minister Laurent Fabius likened the EU to joining a soccer club — "you can't say you want to play rugby," he told France-Info radio.
Britain does not use the euro currency, but membership in the EU has given the U.K. access to the massive joint European market as well as a say in how the region should govern itself and run its financial markets. The country has also benefited from EU funds to build infrastructure such as broadband networks.
German Foreign Minister Guido Westerwelle said his country wants Britain "to remain an active and constructive part" of the EU, but suggested that countries could not be allowed to write their own terms for EU membership, saying "a policy of cherry-picking won't function."
Italian Premier Mario Monti said the EU does not need "unwilling members," adding that he hopes British citizens will decide to remain in the bloc and help shape its future. He said the referendum would be best framed with a direct question — up or down on membership — rather than a fuzzier query for voters.
"I think there is an advantage in the idea of eventually putting to the people the real question in a referendum," he said.
Cameron stressed that his first priority is renegotiating the EU treaty — not leaving the bloc.
"I say to our European partners, frustrated as some of them no doubt are by Britain's attitude: work with us on this," he said.
Cameron said a new EU treaty should reshape the bloc, protect and complete the single market, allow the transfer of powers on issues from crime to working hours back from Brussels to national governments, and make Europe's economy more competitive and its institutions more flexible and democratically accountable.
Cameron insisted Wednesday that a "one size fits all" approach to the EU is misguided.
"Let us not be misled by the fallacy that a deep and workable single market requires everything to be harmonized," he said. "Countries are different. They make different choices. We cannot harmonize everything."
Chancellor Angela Merkel said Germany is "of course prepared to talk about British wishes, but we must always bear in mind that other countries have other wishes."
Her foreign ministry spokesman Martin Schaefer added that Britain could lose future economic benefits if it exits the EU, for example if tentative talks on a free trade deal between the U.S. and EU are successful.
"If such negotiations lead to a conclusion the fruits will only be available to those who are members of the union," he told reporters in Berlin.
Even as he raised the spectre of a referendum, Cameron reiterated his view that Britain should stay in the EU.
"I speak as British prime minister with a positive vision for the future of the European Union. A future in which Britain wants, and should want, to play a committed and active part," Cameron said. "There is no doubt that we are more powerful in Washington, in Beijing, in Delhi because we are a powerful player in the European Union."
In Washington, White House spokesman Jay Carney said the administration welcomes Cameron's call for Britain to remain an active force in the EU.
"We believe that the United Kingdom is stronger as a result of its European Union's membership and we believe the European Union is stronger as a result of having the United Kingdom in the EU," he said.
The timeline Cameron laid out mostly hinges on a Conservative victory in the next general election. But he said legislation will be drafted before 2015 so that if his party wins, it can be introduced and passed quickly to ensure a vote could be held "in the first half" of the next Parliament.
Cameron's proposals drew lukewarm support from the foreign minister of the Netherlands, where the prime minister was initially slated to give his speech last week before it was postponed due to the Algeria hostage crisis.
Frans Timmermans said in a statement that the Netherlands agrees with many of Cameron's criticisms of the EU.
"That's why we want to keep the British on board in the EU," he said. "Because you reform the EU from within, not by walking away."
Associated Press writers Elaine Ganley in Paris; Geir Moulson, David Rising and Frank Jordans in Berlin; Don Melvin in Brussels and Angela Charlton and David McHugh in Davos, Switzerland, contributed to this report.
Cassandra Vinograd can be reached at http://twitter.com/CassVinograd