It allows for a vote before the end of that year and will give 16 and 17-year-olds the chance to take part. Voters will be asked one 'yes or no' question on independence.
Mr Cameron immediately said he will be campaigning "passionately" for the United Kingdom to continue, while the First Minister said he was confident that Scotland will vote for independence. The Prime Minister urged those in favour of more powers for the Scottish Parliament to vote 'no', saying the independence question must be settled first.
Mr Salmond said once the positive case for a separate country was put forward people would decide independence was in Scotland's best interests.
After a meeting between the leaders – to ratify a deal agreed last week by Deputy First Minister Nicola Sturgeon and Scottish Secretary Michael Moore – the Edinburgh Agreement, the settlement which will make a referendum legal, was signed.
The UK Government will now issue a Section 30 Order, which, after being approved by Westminster and Holyrood parliaments, will allow the Scottish Parliament the legal basis to hold the referendum.
Both leaders later returned to their campaign messages.
Mr Salmond said: "This will be a referendum designed and delivered by the Scottish Parliament.
"The Scottish Government has an ambitious vision for Scotland: a prosperous and successful European country, reflecting Scottish values of fairness and opportunity, promoting equality and social cohesion.
"A Scotland with a new place in the world – as an independent nation. Today's historic signing of the Edinburgh Agreement marks the start of the campaign to fulfil that ambition."
Mr Cameron said: "All those who want to see not only the status quo but further devolution from the United Kingdom to Scotland must vote to stay within the United Kingdom.
"Of course, I passionately believe in the United Kingdom. I think the rest of the United Kingdom, England, Wales, Northern Ireland, is better off with Scotland in the United Kingdom.
"My argument will also be to English people and Welsh people and Northern Irish people as well as to Scottish people, but as I say I'll be one voice of many but yes, I will campaign hard to keep the United Kingdom together."