David Cameron has said the British people must "have their say" on Europe as he pledged an in/out referendum if the Conservatives win the election.
The prime minister said he wanted to renegotiate the UK's relationship with the EU and then give people the "simple choice" between staying in under those new terms, or leaving the EU.
The news was welcomed by Eurosceptics who have long campaigned for a vote.
France and Germany both warned the UK could not "cherry pick" EU membership.
During noisy Prime Minister's Questions exchanges in Parliament, Labour leader Ed Miliband said Mr Cameron was "running scared" of the UK Independence Party, whose poll ratings have been rising.
Mr Miliband, who said he opposed holding an in/out referendum, said Mr Cameron was "going to put Britain through years of uncertainty, and take a huge gamble with our economy."
In his long-awaited speech, welcomed by many Conservative MPs, Mr Cameron pledged to hold a referendum during the early part of the next parliament - by the end of 2017 at the latest - if the Conservatives win the next general election.
He said it would be a decision on the UK's "destiny" and, if he secured a new relationship he was happy with, he would campaign "heart and soul" to stay within the EU.
"It is time for the British people to have their say," he said. "It is time to settle this European question in British politics. I say to the British people: this will be your decision."
However, Mr Cameron did not spell out what powers he would like to see the UK take back as part of a new settlement or what would happen if the negotiations did not go his way.
'Very simple choice'
The Conservative leader has been under pressure from many of his MPs to give a binding commitment to a vote on Europe.
Mr Cameron said "disillusionment" with the EU was "at an all-time high" and "simply asking the British people to carry on accepting a European settlement over which they have had little choice" was likely to accelerate calls for the UK to leave.
"That is why I am in favour of a referendum," he said. "I believe in confronting this issue - shaping it, leading the debate. Not simply hoping a difficult situation will go away."
Setting out the conditions for a future poll, he said he would seek a "mandate" for a renegotiation and a referendum in the next Conservative election manifesto.
"And 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 EU on these new terms; or come out altogether. It will be an in/out referendum."
But he said holding such a referendum now would be a "false choice" because Europe was set to change following the eurozone crisis and it would be "wrong to ask people whether to stay or go before we have had a chance to put the relationship right".
Mr Cameron said he understood "the appeal" of Britain going it alone and he was sure the UK would survive outside the EU. But, he said, the UK must think "very carefully" about the implications of withdrawal for its prosperity and role on the international stage.
"If we left the European Union, it would be a one-way ticket, not a return," he added.
The prime minister rejected suggestions that a new relationship was "impossible to achieve", adding that he would prefer all other EU countries to agree a new treaty but would be prepared to seek negotiations on a unilateral basis.
However French foreign minister Laurent Fabius warned: "You can't do Europe a la carte... to take an example which our British friends will understand - imagine Europe is a football club and you join, once you're in it you can't say 'Let's play rugby'".
German foreign minister Guido Westerwelle said Germany wanted the UK to "remain an active and constructive part of the European Union... but cherry picking is not an option" before adding that Europe needed more, not less, integration.
Conservative MPs who want a looser relationship with the EU said Mr Cameron's promise a "watershed" moment.
Douglas Carswell told the BBC it was the speech he had "been waiting to hear from a Conservative prime minister all my adult life", while Mark Pritchard said it was "a major triumph" and would unite his party.
Mayor of London Boris Johnson said the British people had not been consulted on Europe since 1975, and it was "high time" they were.
But the former European commissioner and Labour cabinet minister Lord Mandelson told the BBC that Mr Cameron was putting forward a "completely bogus and rather phoney set of demands and circumstances" designed to appease critics in his party.
Shadow foreign secretary Douglas Alexander added: "We understand the need for change but I don't honestly believe the best way to get change in a club of 27 is to stand at the exit door demanding change or threatening to leave."
Former Labour Prime Minister Tony Blair said it was a worrying that the UK had put its departure from the EU "on the table".
He told BBC Radio 4's The World at One: "It reminds me a bit of the Mel Brooks comedy Blazing Saddles where the sheriff, at one point during it, holds a gun to his own head and says: 'If you don't do what I want I'll blow my brains out.' - you want to watch that one of the 26 (other EU members) don't say just go ahead."
'Threatening to leave'
The Lib Dems, who are the junior partner in the UK's governing coalition, say pursuing a wholesale renegotiation of the UK's membership will cause uncertainty.
Lib Dem leader Nick Clegg, who is also deputy prime minister, said "years of uncertainty" caused by a future referendum would hit jobs and growth and this "was not in the national interest".
And former Lib Dem leader Charles Kennedy told the BBC he could not see his party agreeing to a referendum if the Conservatives failed to win a majority at the next election and approached it to form another coalition.
The UK Independence Party said the "genie was out of the bottle" about a possible exit from the EU.
"Winning this referendum, if and when it comes, is not going to be an easy thing but I feel that UKIP's real job starts today," the party's leader Nigel Farage said.
John Cridland, director-general of employers' group, the CBI, said "closer union of the eurozone is not for us" but Mr Cameron "rightly recognises the benefits of retaining membership of what must be a reformed EU".
John Longworth, director general of the British Chambers of Commerce, said the announcement showed Europe had to take the PM seriously, but added: "The lengthy timescale for negotiation and referendum must be shortened, with the aim of securing a cross-party consensus and the outline of a deal during this Parliament."
The BBC's Steve Evans in Berlin said opinion was hardening in Germany and France, with many politicians believing that those opposed to further European integration would be better off "leaving gracefully".
The speech, which has been in the planning for six months, had been scheduled for last Friday in the Netherlands, but was postponed because of the Algerian hostage crisis.