In the most important foreign policy speech of his premiership, David Cameron promises a referendum on Britain's membership of the European Union if the Conservatives win the next election.

Please wait while this video loads. If it doesn't load after a few seconds you may need to have Adobe Flash installed.

The prime minister said he would seek to renegotiate Britain's relationship with the EU and put this to the voters in a referendum after the next election, with a no vote leading to withdrawal.

He said: "The next Conservative manifesto in 2015 will ask for a mandate from the British people for a Conservative government to negotiate a new settlement with our European partners in the next parliament.

"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."

The prime minister was due to make his speech in Amsterdam last Friday, but decided to postpone it to deal with the hostage crisis in Algeria. It was delivered very early today because Mr Cameron had to prepare for prime minister's questions in the Commons at lunchtime.

'Running scared'

In the Commons, Labour leader Ed Miliband accused Mr Cameron of "running scared" of Ukip and his own backbenchers.

He said Labour "do not want an in-out referendum" and asked the prime minister if he would vote yes in a referendum if he failed to achieve his negotiating goals.

Mr Miliband added: "He is going to put Britain through years of uncertainty and take a huge gamble with our economy."

More from Political Editor Gary Gibbon: Cameron speech - Germany's not clapping

In his speech, Mr Cameron said: "It is time for the British people to have their say. It is time to settle this European question in British politics.

"I say to the British people - this will be your decision and when that choice comes, you will have an important choice to make about our country's destiny."

The prime minister set out what he called "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".

In the most important foreign policy speech of his premiership, David Cameron promises a referendum on Britain's membership of the European Union if the Conservatives win the next election.

'Drift towards the exit'

But he said the public needed to be convinced about the benefits of EU membership or there was a danger "the British people will drift towards the exit".

Public disillusionment with the EU was "at an all-time high", he said, adding: "People feel that the EU is heading in a direction that they never signed up to. They resent the interference in our national life by what they see as unnecessary rules and regulation, and they wonder what the point of it all is.

He rejected claims that he will be unable to persuade other EU member states to agree reforms to suit Britain.

"I have no illusions about the scale of the task ahead. I know there will be those who say the vision I have outlined will be impossible to achieve, that there is no way our partners will co-operate, that the British people have set themselves on a path to inevitable exit, and that if we aren’t comfortable being in the EU after 40 years we never will be.

"But I refuse to take such a defeatist attitude – either for Britain or for Europe."

Speaking on Channel 4 News, Foreign Secretary William Hague said the government wanted to "improve the relationship [with Europe], arrive at a new settlement and say to the British people it's OK to stay in the European Union." However Mr Hague declined to specify which policy areas would be up for discussion, saying "you can't today set the list for the negotiations".

Please wait while this video loads. If it doesn't load after a few seconds you may need to have Adobe Flash installed.

Divisions

The prime minister's confirmation that he will seek a renegotiation of Britain's relationship with the EU pleased many Conservative MPs, but opened up divisions with the party's Liberal Democrat coalition partners.

A no vote in the referendum, which would be held by the end of 2017, would mean Britain pulling out of the EU, a prospect Mr Cameron and Chancellor George Osborne would not welcome.

Both of them champion the benefits of the European single market, but resent what they regard as unwarranted interference from Brussels in the affairs of nation states.

The Conservatives hope renegotiation will see Britain exempted from the EU's labour market rules (including the maximum 48-hour working week), in addition to the opt-out from the union's police and justice policies that is currently being sought.

There is now the prospect of uncertainty for British businesses that trade with the continent, a point made forcibly this month by former Conservative deputy prime minister Michael Heseltine.

But a poll published by the British Chambers of Commerce found that 47 per cent of its members wanted "a looser relationship ... but with the UK remaining a member of the EU".

Second referendum

It will be the second referendum on Britain's European membership, with current polls showing a majority in favour of an exit.

Britain joined the European Economic Community (EEC) in 1973 when Ted Heath was prime minister. In the run-up to the 1974 elections, Harold Wilson promised the voters they would be given a say on Britain's membership in a referendum if Labour won.

Labour was deeply split and most voters favoured withdrawal, but with Mr Wilson newly elected and arguing in favour of a yes vote alongside the Tories, there was a two-thirds majority for staying in.

Could Britain end up leaving the EU? The key questions