Context: Kirk Alloway was a small church near where Burns spent the last years of his life. As a young man, he had listened to legends of ghosts told him by Betty Davidson, an old lady with the best collection of horror yarns in the surrounding region. In 1789 Burns dug into his memory for some of them. An antiquarian, Captain Francis Grose, was collecting material in the neighborhood for a book to be called Grose's Antiquities of Scotland. Burns asked him to sketch the church and cemetery where his father was buried and where he himself expected to have his grave. The author agreed, on condition that Burns would provide him with a legend to be printed along with the sketch. So in one day Burns completed one of his greatest poems, the legend of Tam o' Shanter. Tam is a ne'er-do-well, a drinker who stays away from his nagging wife Kate, on market days, not going home until he has spent most of the money he has taken in. However, on this particular day, eventually he heads homeward through the storm, on his horse Meg. His road leads past Kirk Alloway which, to his amazement, is brightly lighted. Since John Barleycorn gives men courage even to confront the Devil, Tammie spurs his horse close enough that he can look on the revelry. Presided over by Old Nick, warlocks and witches are dancing reels so furiously among the open coffins that the women are discarding their garments. Most of them are so old and ugly that Tam is disgusted, but there is one winsome wench, Nannie, in a cutty sark (short shift), who dances so madly and is so pretty that the onlooker, forgetting the circumstances, calls out, "Well done, Cutty-sark!" Out go the lights! The evil dancers come after Tam, who spurs his horse. Every Scot knows that witches cannot cross a stream of running water, so Tammie heads Meg for the bridge.
Once beyond the key stone, in the middle, he will be safe. But Nannie follows swiftly. At the moment she overtakes Tam, everything except the tail of his horse is beyond the middle of the stream, but she seizes that, and off it comes in the witch's grasp, leaving only a stump. In concluding, Burns appends a moral. Before you take a drink or focus your mind on scantily clad women, pause and remember Tam o' Shanter. Here is the conclusion:Ah, Tam! ah, Tam! thou'll get thy fairin!In hell they'll roast thee like a herrin'!In vain thy Kate awaits thy comin!Kate soon will be a woefu' woman!Now, do thy speedy utmost, Meg.And win the key-stane of the brig . . .Ae spring brought aff her master hale,But left behind her ain gray tail;The carlin claught her by the rump,And left poor Maggie scarce a stump.Now, wha this tale o' truth shall read,Ilk man and mother's son, take heed;Whene'er to drink you are inclin'd,Or cutty-sarks run in your mind,Think, ye may buy the joys o'er dear,Remember Tam o' Shanter's mare.