Image caption A BBC Alba documentary is telling the Deacon Brodie story

Deacon Brodie's pub at the top of the Royal Mile is a well-known Edinburgh landmark but how many people know the real story of his outrageous life and crimes?

On 1 October 1788 William Brodie was hanged for theft in the Lawnmarket in front of a crowd that was the largest seen in living memory.

He strode out to the gallows in fine clothes and a powdered wig. A fitting end to an extraordinary life.

It is said that Brodie's double life was the inspiration for Edinburgh author Robert Louis Stevenson's infamous character Dr Jekyll and Mr Hyde, which was published a century later.

But who was Deacon Brodie?

He was 47 when he was hanged and until his arrest had managed to maintain the illusion of being a respectable craftsman.

"He was bourgeois, he was respectable, he was the sort of person whom the criminal classes were supposed to look up to," says Edinburgh University historian Owen Dudley Edwards.

The prestigious title of deacon did not refer to religion, as many assume, but instead to his presidency of one of Edinburgh's trades guilds.

His trade was as a cabinet-maker and his position as deacon of the Incorporation of Wrights made him a member of the town council.

"In those days it was inconceivable that the public would have a say in who their councillors would be," says author Ceitidh Mhoireach.

So Brodie, as a representative of a guild, was given a position of influence in the running of the city.

Both Brodie's grandfathers were renowned Edinburgh lawyers and his father was a successful businessman.

Brodie himself was a fine craftsman specialising in domestic furniture such a cupboards and cabinets - crucially, he was also a talented locksmith.

Through his work he had access to the houses of very rich people and was able to make impressions of keys which meant he could come back at night and rob them.

It is thought his criminal career began in 1768 when he copied keys to a bank door and stole £800.

But it was not until more than a decade later that Brodie's crime spree got going properly.

Brodie's father died of palsy in 1782 and the son became a wealthy man.

His father left him £10,000 in cash alone, a fortune in those days, plus at least four houses and the business.

But by this time his lifestyle was getting very expensive.

He had been a member of The Cape, the most exclusive club in Edinburgh, but over time his interests turned to a disreputable tavern in Fleshmarket Close, which was notorious for late-night drinking and gambling with cards and dice.

He was also keen on gambling on cock fighting.

"He would appear to have lost a lot of money," says criminal lawyer Iain MacDhugaill.

In addition to his gambling, he was also supporting two mistresses and five children.

He ran up debts during the night but his daytime business was thriving.

Private homes

However, Brodie seems to have wanted to supplement his income.

In the summer of 1786 an unusual Englishman arrived in the city.

Things might have turned out differently if George Smith and Brodie had never met.

The pair soon became extremely busy targeting businesses and private homes in the Old Town.

Towards the end of 1786 Brodie and Smith robbed a goldsmith's and a tobacconist's.

On Christmas Eve they made off with a major haul from Bruce Brothers, including watches, rings and lockets.

Before long they got involved with another two criminals, John Brown and Andrew Ainslie.

By the summer of 1787 they had ventured further afield to Leith where they stole tea, a valuable commodity at the time, from a grocer's shop.

Previous robbery

Shortly after this they stole the ceremonial mace from the University of Edinburgh.

The gang were riding high and decided on their most daring crime yet.

"They tried, very audaciously, to steal the revenues of Scotland," says author Rick Wilson.

The Excise Office in Edinburgh was in Chessel's Court at the bottom of the Royal Mile.

For this job, possibly for the first time, the gang were armed with pistols and, also unusually for them, they broke in.

They were disturbed and fled with just £16. It was a fiasco and it led to the gang falling out.

John Brown was tempted by the reward of £150 being offered for information about a previous robbery and went to the sheriff's clerk to name Ainslie and Smith as the culprits.

When they were arrested Brodie feared the game was up and prepared to flee. He took the stagecoach to London and then a ship to Holland.

But the reward for Brodie's capture led to him being tracked down and discovered as he hid in a cupboard in an inn.

He was returned to Edinburgh where he stood trial with Smith.

His trial lasted just 21 hours.

He was hanged in front of a crowd of 40,000.

The Real Jekyll & Hyde? Sgeulachd Deacon Brodie, broadcast at 21:00 on 29 January on BBC ALBA.