Alex Salmond has signalled the start of a two-year campaign to persuade the Scottish electorate to embrace independence, after agreeing a referendum deal with David Cameron.

After more than eight months of intense negotiations, the Scottish first minister and the UK prime minister signed a detailed 30-clause agreement in Edinburgh to stage a referendum before the end of 2014 asking a simple yes or no question on whether Scotland should become independent.

The deal, dubbed the Edinburgh agreement by Salmond, states that both governments "look forward to a referendum that is legal and fair producing a decisive and respected outcome". The leaders said they would respect and uphold the result.

The Scottish National party leader said the deal, agreed less than 18 months after he won a landslide victory to take control of the Scottish parliament, "paves the way for the most important decision that our country, Scotland, has made in several hundred years. It is in that sense an historic day for Scotland, a major step forward in Scotland's home rule journey".

Salmond said he believed "heart and soul" he could win the referendum but, in a rare admission about the scale of the task facing his government and the Yes Scotland campaign, he acknowledged he still needed to persuade a majority of the country's 4 million voters to back independence.

Although the SNP remains the most popular party for voters in Holyrood opinion polls, a Comres/ITV News poll published on Monday found that a majority of Scots (55%) opposed independence, with just over a third (34%) in favour.

Salmond referred several times to the quest for home rule as being a "journey", a phrase many observers and critics will see as a tacit admission that he fears the SNP may be defeated and instead have to accept greater devolution to Scotland within the UK. Significantly, the phrase "home rule" has been most commonly used to refer to devolution, not to outright independence.

"Given the proper opportunity, we – the campaign, the SNP, the other parties supporting it, the civic Scotland people supporting this campaign – will be able to convince a majority of our fellow citizens that this is the right future for Scotland," Salmond said.

Using noticeably cautious language, he said "if the campaign is pitched correctly and positively about the future of this country", then it would win the referendum.

"Just as I have believed in independence all my life, I believe in that heart and soul," he said.

Immediately after signing the document alongside the Scottish secretary, Michael Moore, and Salmond's deputy, Nicola Sturgeon, Cameron left St Andrew's House, the Scottish government's administrative headquarters in central Edinburgh, without a word to the waiting media.

With access to and from the building very tightly controlled, and the street outside the building closed to all traffic, the muted atmosphere belied the occasion. Apart from a lone shout from one nationalist of "vote yes for independence, Mr Cameron" as the prime minister arrived to meet Salmond at 12.20pm, there were no demonstrations by either supporters or opponents of independence.

In a series of television interviews, Cameron said he had delivered on his promises to Salmond and Scottish voters to give the Scottish parliament in Holyrood the legal right to stage a vote on independence.

He said he would fight vigorously to keep Scotland a full part of the UK. "This is an important day for the United Kingdom, but you can't haul the country of the United Kingdom against the will of its people. Scotland voted for a party that wanted to hold a referendum," he said. "I want to be the prime minister that keeps the United Kingdom together, but I believe in showing respect to people in Scotland.

"The people of Scotland voted for a party that wanted to have a referendum on independence. I've made sure, showing them respect, that we can have that referendum in a way that is decisive, that is legal, that is fair but crucially is one single simple question, whether Scotland wants to stay in the United Kingdom or go."

Cameron had earlier visited a military warship dockyard at Rosyth, Fife, where engineers are assembling the first of the Royal Navy's new aircraft carriers – a site chosen for its symbolism.

Downing Street believes the UK government achieved a strategic success in forcing Salmond to drop demands for the Scottish parliament to be allowed to stage a two-question referendum, including an extra option of greater devolution within the UK.

In exchange, Salmond will be allowed to hold the referendum in 2014, a year later than No 10 had originally hoped, and 16- and 17-year-olds will be given the right to vote. "All that mattered was the question – everything else was marginal," one UK government source said.

That was heavily criticised by one of Scotland's leading supporters of a second option, Martin Sime, chief executive of the Scottish Council for Voluntary Organisations. "A strong majority of people want more powers short of independence but the referendum will deny them the chance to vote for the kind of change they want to see," Sime said. "The politicians are back in charge and now we have two years of yes/no politics ahead of us whilst savage welfare cuts affect the poorest people across Scotland. This is not a recipe for successful democracy."

Salmond said he regretted losing that debateand blamed the hard-headedness of the UK government, but said compromise was in the nature of all negotiations. That meant, however, that his government had been able to make "significant gains" by achieving a legally watertight referendum that would deliver a fair and decisive outcome.

Many observers believe that Salmond was extremely keen to stage a two-option referendum because he believes winning a yes/no vote on independence will prove much harder.

"It's quite true that we didn't deliver that objective, of allowing the Scottish parliament to have a provision including the question of whether there should be one or two questions. But in terms of any negotiations, there has to be an element of compromise," Salmond said. "I can understand why people might have wished to have a second question on the ballot paper but it was not an agreement foreclosed on by us; it was foreclosed on by the Westminster government."

As widely expected, the deal will give the Scottish parliament the temporary legal power to stage a single-question referendum on Scottish independence until the end of 2014. The wording of the question, campaign financing and the designating which groups and parties can officially take part in the campaign will be overseen by the UK Electoral Commission under UK referendum law.

The referendum is widely tipped to be held in October 2014, and Salmond confirmed he had a date in mind, but refused to disclose it, adding to expectations that disclosure may be the centrepiece of his keynote speech to the Scottish National party's annual conference in Perth this Saturday.

The 30-clause agreement also confirms the Scottish parliament has the authority to widen the franchise to 16- and 17-year-olds, a measure Cameron had opposed. And in further concessions, the Scottish parliament will be allowed to ignore UK election rules that allow the Electoral Commission to oversee the conduct of the referendum, announcing the result and giving public grants to campaign organisations – a provision the Scottish government has resisted.

After disagreements over how long the final official campaign in 2014 would last, the agreement has confirmed it will last 16 weeks.

Timeline

22 October 2012 A section 30 order formally but temporarily transferring the power to hold an independence referendum will be laid in Westminster, as the Scottish government publishes its long-delayed report on the 24,000 public responses to its referendum consultation.

February 2013 The section 30 order, which amends the Scotland Act 1998 that originally set up the Scottish parliament in Edinburgh, will be agreed by the Privy Council in London, formally conferring that temporary power to stage the referendum to Holyrood.

Spring 2013 The Scottish government will present a referendum bill to Holyrood, setting out the question, putting limits on campaign spending and confirming whether 16- and 17-year-olds will be allowed to vote.

November 2013 After a final vote expected in October 2013, the Queen is expected to give royal assent to the referendum bill. The Scottish government will publish a white paper finally detailing its "prospectus for independence", setting out the Scottish National party's vision for an independent Scotland.

June 2014 The final 16-week referendum campaign is expected to start, when both pro-independence and pro-UK campaigns will intensify.

Autumn 2014 The Scottish independence referendum takes place, probably in October. Alex Salmond is believed to favour Saturday 14 October but has yet to formally confirm any date.

• This article was amended on 16 October 2012 to correct a reference to Holyrood that was misspelled as Holywood.