Greyfriars Kirk in Edinburgh is best known for the tale of a loyal dog named Bobby - but it has also played a role in Scottish history and helped inspire some literary legends.
Here are some of the most notable chapters from the history of the church, which has announced a series of events to celebrate its 400th anniversary this year.
The legend of Greyfriars Bobby
The story of Greyfriars Bobby came to wider attention in the latter half of the 1800s after he became a celebrity in Edinburgh.
The loyal Skye Terrier is said to have guarded the grave of his master, John Gray, in Greyfriars Kirkyard for 14 years.
His period of mourning lasted until Bobby's own death in 1872. The terrier is also buried within the graveyard.
The tale has inspired books and films, and a statue of Bobby on the corner of Candlemaker Row and George IV Bridge is visited by thousands of tourists every year.
So many people have rubbed the statue's nose that the paint has now been rubbed off, revealing the brass underneath.
Inspiring JK Rowling
The graveyard is also a place of pilgrimage for Harry Potter fans, after author JK Rowling revealed that the gravestones had inspired the names of some of her characters.
She wrote part of the novels in the Elephant House cafe around the corner from the church.
Tourists now visit the graveyard to see the grave of Thomas Riddell, who died in 1806, and his son, also Thomas, who died in Trinidad in 1802 at the age of 26.
Their names were used as inspiration for the character of Tom Riddle - otherwise known as Lord Voldemort.
William McGonagall, who has a reputation as one of Scotland's worst poets, is also buried in the graveyard. JK Rowling used his name for Hogwarts' Prof Minerva McGonagall, the head of Gryffindor.
Other gravestones are said to have inspired the names of characters such as Alastor "Mad Eye" Moody and Rufus Scrimgeour.
The kirkyard is also rumoured to have been the inspiration behind the resting place of Harry's parents in Godric's Hollow.
The National Covenant
The National Covenant, which demanded radical changes in how Scotland was governed, was signed in the graveyard in February 1638.
The document was drawn up to oppose religious and political policies which had been introduced by King Charles I.
The Covenant was a promise to uphold Presbyterian values. The Covenanters refused to accept the King as the spiritual head of the church in Scotland, and opposed the Episcopalian system of church government.
Charles regarded this as treason and declared war on the Covenanters - a move which eventually led to civil war across England, Scotland and Ireland.
Part of the graveyard was later used as a prison for Covenanters who had been defeated that year by government forces at the Battle of Bothwell Bridge in 1679.
For more than four months the men were held in the prison without any shelter, with each man only allowed 4oz of bread a day.
Some prisoners died and others were tried and executed for treason.
The untended grave
Sir George MacKenzie was the man who rounded up the 1,200 Presbyterian Covenanters at Bothwell Bridge and imprisoned 400 of them in the graveyard.
Mackenzie was said to be responsible for killing nearly 18,000 people during an eight-year period in Scottish history which was dubbed The Killing Time.
He became known as Bloody MacKenzie - and as a result, his domed mausoleum in the graveyard is not maintained out of disrespect for his deeds.
In 2003 two boys, aged 17 and 15, entered the tomb through a ventilation slot in the rear of the building, which has now been sealed.
They reached the lower vault containing the coffins, broke the coffins open and stole a skull.
Police arrived as they were playing football with the skull on the grass.
The great and the good
The graveyard is also the final resting place of other figures who shaped the city of Edinburgh.
They include the poet Allan Ramsay; New Town architect James Craig; the Encyclopaedia Britannica's William Smellie; and Sir Walter Scott's father, Walter Scott.
The founder of Edinburgh school Mary Erskine's is also buried at Greyfriars, along with some leading figures from the Scottish Enlightenment.
This period, in 18th and early 19th Centuries, saw many intellectual and scientific accomplishments.
The Enlightenment culture was based on close readings of new books, and intense discussions took place daily at intellectual gathering places in Edinburgh and other Scottish cities.
The figures buried in Greyfriars include printer and naturalist William Smellie, geologist James Hutton; and Scottish architects William Adam and John Adam.