In Edinburgh's Old Town as the proclamation for King Charles III was read out and a gun salute echoed from the city's ancient castle, a small but noisy group of protesters began heckling.
In a ceremony dating back centuries, a government official dressed in red ceremonial robes stood on a stone plinth outside St Giles' Cathedral and read the proclamation. He then declared "God Save the King" and the crowd shouted the phrase back.
Connor Beaton, a 26-year-old wearing a t-shirt with the words "another Scotland is possible", had been waiting for this moment. He cupped both his hands around his mouth and began booing as loud as he could.
Other protesters held up signs saying: "Republic Now", and "Our Republic for a Democratic Future". The police arrested one woman after she held up a handwritten sign saying: "Fuck Imperialism. Abolish the monarchy".
In Scotland, the death of Queen Elizabeth has led to a moment of national reflection in a restless country. There is both admiration for the monarchy and those who feel her death marks the closing of a long chapter.
It will also fuel the already heated debate on whether Scotland should be independent.
England's political partner for more than 300 years, Scotland rejected by 55% to 45% the chance to leave in a 2014 referendum. But differences over Brexit when Scotland and Northern Ireland voted to stay, but England and Wales voted to leave, has increased support for independence.
The United Kingdom government has repeatedly rejected the Scottish government's demand for a second independence referendum.
Next month Britain's top court is set to hear a case about whether the Scottish parliament may legally hold a second referendum to leave the United Kingdom.
Outside St Giles' Cathedral on Sunday, the crowd initially gasped when the protesters started. Then people shouted "shut up", "go home", and "you are a disgrace". One lady said: "I might do them in."
Beaton rejected suggestions he was being insensitive because it was only three days since the death of Queen Elizabeth. He said it is undemocratic to have a monarchy at the centre of a constitutional democracy.
"It is only right that we can show that not everyone agrees with the pageantry and the archaic institution that is the monarchy," he later told Reuters.
Scotland's relationship with the monarchy pre-dates the political union with England in 1707 by a century and they exist largely as separate entities.
The two countries have shared the same monarch since the early part of the seventeenth century when the death of the childless Elizabeth I led James VI of Scotland to merge the crowns.
Some Scots support independence but want to keep the monarchy.
But other nationalists hope the queen's passing will eventually give them an opportunity to open up a new front in the battle for independence, and ultimately to break the link with the British crown to become a republic.
The queen, who spoke about her deep affinity for Scotland, was for some the personification of the British identity. While the British monarch is meant to be politically neutral, the queen hinted at key moments of her desire for Scotland to remain part of the four countries in the United Kingdom.
Her death in Scotland, at her summer home Balmoral Castle in the Scottish Highlands, underscored her close ties to the country. For the next two days, Scotland will be the centre of national mourning.
Tens of thousands of people lined Edinburgh's Royal Mile on Sunday to glimpse the queen's hearse as it made its way to the royal residence in the Scottish capital. Locals said it was the busiest they had ever seen the streets in the capital.
The queen's coffin will be moved to St Giles' Cathedral on Monday. After a service, people in Scotland will be the first among anyone in the United Kingdom to have the opportunity to file past and pay their respects.
While the ruling Scottish National Party's policy is that it wants to keep the monarchy even if Scotland wins independence, some nationalists openly say that if Scotland becomes independent then the public should choose between keeping the monarchy or electing a head of state.
Scotland has traditionally been more sceptical about the monarchy than other parts of the United Kingdom, and the institution is declining in popularity. In May, a poll found 36% believed the end of the queen's reign would be the appropriate moment to become a republic.
Broadly in line with the main fault lines on whether Scots want independence, there is a generational divide where elderly residents express devotion to the royals and younger locals said they felt little connection to the family.
John Hall, a 33-year-old business owner, was among the protesters on the Royal Mile. He pointed to the crowd of men dressed in heraldic outfits proclaiming the new king and said: "I find it hard to believe that this is happening in Scotland in the 21st Century."
Robert Miller, a 60-year-old civil engineer, who supports the monarchy, confronted the protesters, and told them: "wrong time, wrong place". He stressed the number of protesters was small and unreflective of the mood of most of the crowd.
Colin Girvan, 61, a manager at a metal sheets factory from Glasgow, who was visiting Edinburgh to pay his respects to the queen, said he hoped that the end of Elizabeth's reign would not end a political union she devoted much of her life to preserving.
"There's a strong bond with the union," he said. "I am Scottish first and foremost, but I am British. I relate to being British."