EDINBURGH — Over a Michelin-starred dinner of Scottish venison and red Burgundy in February 2012, Prime Minister David Cameron of Britain outlined his strategy for defeating a Scottish independence referendum.

The Scottish National Party had won a landslide victory in voting for the Scottish Parliament the previous May, on the promise of a secession vote. The party’s leader, Alex Salmond, was determined to make good on that pledge, presenting Mr. Cameron with a quandary: Ignore the issue and appear unresponsive to the will of the Scots, or let the vote happen and accept its risks.

Huddled in the Peat Inn near the Scottish university town of St. Andrews, Mr. Cameron told a group of advisers that Mr. Salmond would have his referendum. But he would refuse the demand for a second, softer option on the ballot for more autonomy for Scotland. He would call Mr. Salmond’s bluff. There would be a single question: Should Scotland stay inside the United Kingdom or leave it forever?

That, the prime minister confidently predicted, according to a person who was at the dinner, would “put the issue to bed.”

It has not turned out that way. When Scots cast their ballots on Thursday, a decision in favor of independence is a real possibility. And Mr. Cameron and the other major party leaders in London were clearly hoping that last-minute promises to grant Scots the very powers he refused to put on the ballot would be enough to head off a separatist victory.

The gamble that Mr. Cameron outlined that cold February night now looks potentially fateful: If Scots vote for independence, it will cost Britain a three-century-old union. It might also cost Mr. Cameron his job, even lawmakers from his own party say. If the Scots vote against, Mr. Cameron nevertheless must give them more autonomy, with potentially cascading implications for the rest of Britain.

“There is no doubt that the middle option would have triumphed, were it on the ballot paper,” said Richard Wyn Jones, a professor at Cardiff University in Wales. “There was nothing inevitable about the calling of the referendum, and nothing inevitable about its result, either — whatever that turns out to be.”

On the long road to the Scottish referendum, three other moments stood out, historians, political scientists and officials said. All were the result of political miscalculation as much as shrewd leadership: The decision in 1989 by Prime Minister Margaret Thatcher, already unpopular after shutting down steel mills and coal mines, to roll out a regressive tax in Scotland before the rest of Britain; the decision by the Labour prime minister Tony Blair to allow Scotland to hold a referendum on greater autonomy in 1997, which led two years later to the establishment of a Scottish Parliament for the first time since 1707; and the crushing 2011 victory of the Scottish National Party, which won an overall majority in the Scottish Parliament and with it a mandate to call a referendum on independence.

Video

In the week ahead of a historic referendum on Scottish independence, campaigners from both sides took to the streets to sway the vote, which could break a three-century-old union.CreditCreditChristopher Furlong/Getty Images

Mrs. Thatcher’s combination of heavy-handedness and neglect north of the border hardened the Scots’ liberal resolve and hamstrung the Tories here: David Mundell is now the only Conservative among the 59 British lawmakers elected from Scotland.

The sense that Scots were being governed by an administration in London that they did not choose was the main reason Mr. Blair’s government agreed to hold the 1997 referendum. What Mr. Blair did not anticipate was that a Scotland with its own Parliament would also turn away from the Labour Party, if not to the same degree.

Before 1997, the Scottish National Party was little more than a fringe voice of romantic protest. In the mid-1990s only one in four Scots voted for the party, while more than 40 percent supported Labour. But the opportunity to govern Scotland transformed the nationalists into a mainstream political force, winning elections in 2007 and 2011 and building up a large majority.

“It was dramatic,” one senior official, who was in Westminster at the time, recalled this week. “This was not only further proof of the death of the Conservative Party in Scotland, this was proof of just how badly Labour had done in a place it once took for granted. Scotland was Labour.”

Video

For Glasgow-based Collins Bartholomew, Scotland’s independence referendum could lead to a redrawing of its world-famous maps.

“We were all out of touch,” the official said. “And now we’re paying for it.”

The few local politicians from the main parties who were prepared to lobby for greater powers for Scotland were often quashed.

One contender for the leadership of the moribund Conservative Party of Scotland, Murdo Fraser, campaigned in 2011 on a radical ticket promising more self-governance. But the London party machine swung behind his opponent, Ruth Davidson, who opposed giving more powers to Scotland.

“If Murdo had won, we wouldn’t have had a referendum, we would have had devo max,” said Andrew Wilson, a former Scottish lawmaker and one of Mr. Salmond’s close associates, using a shorthand expression for maximum autonomy, which might have pre-empted the independence drive.

The day after his election victory in 2011, Mr. Salmond arrived at one of Scotland’s most prestigious hotels in high style, disembarking from a chartered helicopter with a thumbs-up sign.

The Observer newspaper quoted a senior Conservative cabinet minister saying after a meeting with the nationalist leader that “Salmond really thinks he can be the father of his nation, some kind of Ataturk of Scotland.”

But for all the condescension that British leaders reserved for Mr. Salmond at that time, few argued for blocking the referendum altogether. In fact, it was Mr. Cameron who pre-empted Mr. Salmond and announced on television on Jan. 8, 2012, that he was already looking into the legal steps for a referendum.

There was a sense among the British establishment that Mr. Salmond was playing for time, and that the sooner a referendum was held, the less likely it was to succeed. As the columnist Andrew Rawnsley said in The Observer newspaper on Sunday, opinion polls at the time found that “the odds of the Scots voting for independence were only marginally better than the chances of Elvis being found alive in Fort William cohabiting with Dennis the Menace and the Loch Ness monster.”

It was in this context that Mr. Cameron insisted on a single question that, as one official put it, would “settle it for a generation.”

Image

The leader of the Scottish National Party, Alex Salmond, left, and Prime Minister David Cameron of Britain, signed a referendum agreement in 2012.CreditPool photo by Gordon Terris

The calculation inside Downing Street was that in a referendum with three options, the combined votes for independence or for more autonomy would probably outnumber those opting for no change, threatening to keep the issue alive and allow the pro-independence forces to demand another referendum on full independence.

In exchange for giving up the middle option, though, Mr. Salmond won two significant concessions: the right to lower the minimum voting age to 16 from 18 for the referendum and, crucially, an extra year to campaign. Mr. Cameron initially wanted to hold the vote in 2013.

“The nationalists were gifted the commodity they needed most: time,” George Eaton wrote recently in the New Statesman. “Having begun as the underdogs, they have had an extra year to build a grass-roots campaign capable of winning over the undecided.”

Few people at the heart of power grasped how public opinion in Scotland was evolving. Gus O’Donnell, who was the top civil servant in Britain, was a rare exception.

“Over the next few years there will be enormous challenges, such as whether to keep our kingdom united,” Mr. O’Donnell said in The Daily Telegraph in December 2011, when he was leaving office and Mr. Cameron and Mr. Salmond were preparing to start negotiations on the referendum.

But Mr. Cameron failed to see the writing on the wall — and it was on the wall, right behind him, when he sat down with Mr. Salmond to sign the Edinburgh Agreement on the terms of the referendum in October 2012: a large map of Scotland, color-coded by party control, showing a sweeping sea of Scottish Nationalist yellow.

Stephen Castle contributed reporting from Dundee, Scotland.

A version of this article appears in print on , on Page A12 of the New York edition with the headline: On Road to Scotland’s Decision, Gambles and Fateful Steps. Order Reprints | Today’s Paper | Subscribe