Scotland's capital by any standards was historically a somewhat unruly place, and riots of various kinds and causes were a regular challenge to the local constituted authorities throughout the seventeenth and eighteenth centuries. A local police force was only formed in the first decade of the nineteenth century, and before this time only the city's Town Guard could be called upon to police the streets and defend against the Edinburgh mob. The Town Guard was the force first formed in the aftermath of the Battle of Flodden (1513), when panic and looting followed the news of Scotland's disastrous defeat and the Council decreed that every fourth citizen had to take his turn on the watch. It was never a popular force with the city's less privileged classes. In 1736, for example, its commander Captain Porteous was dragged by a furious mob four thousand strong from his cell in the Tolbooth (city prison at the time), where he was awaiting trial for ordering his men to fire upon a riotous assembly, and brutally lynched in the street.
For much of the eighteenth century the Town Guard were the only form of law and order, and as the events of 1736 showed they were certainly capable of using effective force when it was called for. Their lair was the Guard House, an ugly squat building of great antiquity sited in the High Street opposite the Tron Kirk. From here the evening watch issued at eight o'clock every night, beating drums to announce the start of a sort of curfew upon drunkenness.
A wooden horse situated outside the Guard House was the punishment for revellers captured by the Town Guard; the victim would be placed on this with heavy irons attached to each foot and a drinking jug upon his head so that passers-by understood the nature of his offence. The Guard House was demolished in 1785 and the Guard was moved to the Tolbooth, the city's main gaol, further up the High Street. The Tolbooth was in turn demolished in 1817, and its site outside St Giles Cathedral is marked today by brass markers and a stone mosaic amongst the cobbles in the shape of a heart. This is a reference to Sir Walter Scott's novel The Heart of Midlothian, which is centred upon the Porteous riots. The Edinburgh tradition of spitting upon the mosaic as one passes arose originally to express contempt for the old Tolbooth and for public authority, though contempt for a certain football club seems to be the prime motivation today.
By the final decades of the eighteenth century the Town Guard had become something of an anachronism and the butt of local humour. Its members were almost invariably elderly Gaelic-speaking ex-soldiers, a typical example of whom was described by Scott as an "old grey-headed and grey-bearded Highlander, with war-worn features, but bent double by age; dressed in an old fashioned cocked-hat, bound with white tape instead of silver lace; and in coat, waistcoat, and breeches, of a muddy-coloured red, bearing in his withered hand an ancient weapon, called a Lochaber-axe..." It seems that their numbers were continually being reduced and their role restricted by the city fathers, so that by Scott's day they were no longer so much feared as openly mocked: "[They]were neither by birth, education, nor former habits, trained to endure with much patience the insults of the rabble, or the provoking petulance of truant schoolboys, and idle debauchees of all descriptions, with whom their occupation brought them into contact. On the contrary, the tempers of the poor old fellows were soured by the indignities with which the mob distinguished them on many occasions..." Poor old fellows they certainly were, for the pay was sixpence a day and it is recorded that when the Lord Provost inspected their ranks in 1789 he found a Guardsman who had been in the ranks since the Porteous riots of 1736! The man was dismissed and awarded a pension for life.
It would seem that the Edinburgh caricaturist John Kay took a special interest in the Town Guard, as they feature in several of his works. The sketch of John Dhu, described by Scott as "the fiercest-looking fellow I ever saw", was particularly admired by the citizens who gathered around Kay's shop window to gaze at the work the artist displayed there.
With the founding of the city's new police force in 1805 it was clear that the days of the old Guard were numbered, and when the Tolbooth came down in 1817 they were disbanded. Scott recorded the sad spectacle of their march on their final day: "Their last march to do duty at Hallowfair had something in it affecting. Their drums and fifes had been wont on better days to play, on this joyous occasion, the lively tune of 'Jockey to the fair;' but on his final occasion the afflicted veterans moved slowly to the dirge of 'The last time I came ower the muir.' "