EDINBURGH — The Royal Lyceum Theatre here has a modest hit on its hands, a slightly scabrous play that tells the story of Scotland’s parliamentary vote to dissolve itself and join the kingdom of England in 1707.

“Union,” by Tim Barrow, depicts the English as conniving, Queen Anne as a ravenous simpleton and the Scots who voted for union as having been bribed by the English and their agents, who included Daniel Defoe. There is much to tug at the heartstrings of the Scots: a passionate poor Scottish bard, perfidious Englishmen, cynical aristocrats, plenty of sex and almost as much whisky as rain.

Having opened just months before Scotland votes whether to regain its independence, the play has received mixed reviews, which its director, Mark Thomson, described as “up and down, from cardiac arrest and back.” He staged it now, he said, “as a political act, to confront Scotland with itself.”

Barrow says he will vote yes, for Scottish independence, on Sept. 18. Thomson calls himself “one of the great undecided.” After each performance, there is an informal poll among the audience, with a late-night rush to vote in the ballot boxes set up in the foyer, asking whether the union 307 years ago had been a good idea — “Aye” or “Nae.”

Most Read Stories

“Nae,” John Menzies decided, popping his theater ticket into the designated slot.

“We should never have sold out our country in the first place, never,” said Menzies, a 46-year-old graphic designer. “Luckily, we will soon get a chance to set that right.”

The votes for independence seemed to just outnumber those against, reaching a little bit higher in the clear ballot boxes. But in real life the balance is still the other way, with every poll so far giving the pro-union camp a clear though shrinking lead.

For the independence camp it is in many ways a race against time: Over the last six months momentum has shifted toward independence, but at least one-sixth of voters in recent polls have said they were undecided or refused to answer.

“If this referendum was in five years’ time, it would be straightforward,” said Jean Urquhart, an independent member of the Scottish Parliament from the Highlands and Islands who was in the audience. “As it is, it will probably be very close.” Urquhart, an advocate of independence, was elected as a longtime member of the governing Scottish National Party, but as a supporter of nuclear disarmament, left the party in October when it reversed its policy and chose to remain a member of NATO.

Such shifts have caused some doubts about Scottish independence, too, with the party also advocating use of the British pound after independence, instead of the euro, despite statements by all the British parties that an independent Scotland could not be allowed to use the pound. Would an independent Scotland be a member of the European Union? Use the British pound? These questions, which depend on the decisions of others, cannot be easily answered.

With the polls tightening, the former Labour Prime Minister Gordon Brown spoke in Glasgow in April in defense of the union, arguing that Scotland is better off economically inside the United Kingdom, especially in terms of pensions and social welfare.

Sowing doubt about the strength and viability of an independent Scotland’s economy is at the center of the anti-independence campaign, known as “Better Together.” But the no campaign emphasizes the negative, and the sense that the English are patronizing the Scots as ineffectual and incompetent also feeds the independence campaign, stirring indignation.

Evidence of the debate is everywhere, with signs on shop windows displaying the owners’ preference, and stickers like “End London Rule!” plastered to sidewalks.

The referendum, open to anyone registered to vote, is binding and need pass by only one vote.

Seemingly every segment of society has its own campaign for independence, many supported by the Scottish National Party, led by Alex Salmond. There are Yes groups for mothers, students, seniors, small businesses, lesbians, gays and bisexuals — even for taxi drivers (“Cabbies for Yes”).

Iluta Stivrina, 24, moved here four years ago from Latvia. She loves it here, but thinks many Scots do not know what they are really voting for. “I know all the problems of independence for a small country,” she said.

At the Scottish Storytelling Center, which includes a cafe, theater and the medieval residence of John Knox, the father of Scotland’s reformation, the shelves creak with books about Scotland. Chiseled into the modern stone entry is a line from the Scottish novelist Alasdair Gray: “Work as if you live in the early days of a better nation.”

But for Elaine Jenkins, who works there, the debate is getting uncomfortably hot, one reason the center has decided to pull back from debate-related events. “People can get downright nasty about it,” she said.

Jenkins will vote no in September, she said. She said she feels both Scottish and British and will not be bullied into giving up either identity. “On a worldwide scale,” she said, “we’re better off as the U.K.”

But Malcolm Fraser, an Edinburgh architect who designed the storytelling center’s modern building, could not disagree more. A fervent believer in independence, Fraser is on the board of the Radical Independence Campaign. “The way forward is to be small, vigorous, independent and trade with everyone,” he said.

People have become afraid of the passions stirred by the debate, but Fraser said they should not be afraid of that. Britain is undergoing “an inevitable unraveling of empire.” It was time Scotland becomes “a bit more Danish,” saying goodbye to England’s more right-wing politics, he said.

Ian Rankin, a novelist who created the popular and grumpy Inspector John Rebus and his better-adjusted detective sergeant, Siobhan Clarke, is one of Scotland’s stars. Rankin seems genuinely conflicted about how to vote.