William Hamilton of Bangour is invariably so called in order to distinguish him from that other William Hamilton of his time, of Gilbertfield, who was also a poet. The second son of a gentlemen of large fortune, of the estate of Bangour in Ayrshire, he early attained a reputation as one of the most courtly wits of Edinburgh, was much sought after by the fashionable society of the Scottish capital, and is referred to in contemporary correspondence as "the elegant and amiable Hamilton." At the age of twenty he was one of the ingenious young gentleman whom Ramsay acknowledged as contributors to his Tea-Table Miscellany; and he continued to write verse in the affected artificial vein then in vogue in England. A story is told of him which illustrates well the insincerity of the note of passion which it was fashionable for the poets of the day to affect in their verse. A young lady to whom Hamilton had addressed several amatory effusions complained to Home, who was a mutual friend, of the annoyance which these insincere attentions caused her, and begged his interference. Home refused, but with a smile suggested a better plan. "Go you," he said, "to the Assembly to-night, dance with Mr. Hamilton, and show him every mark of attention, as if you took his suit in earnest and were resolved to favour it, and I warrant you shall be troubled no more with these pretences." The young lady did as she was told, and treated Hamilton's attentions as if she took them to be sincere; whereupon the gallant, in alarm, at once cooled his ardours and assumed an air as distant as it was respectful. The poet, however, was twice married, and by his first wife, a daughter of Sir James Hall of Dunglas, he became the father of an only son.
Upon the outbreak of the Rebellion in 1745 Hamilton joined the Jacobite standard, and his enthusiasm after the victory of Prestonpans found expression in an ode, which established him as the laureate of the cause. He escaped from the overthrow at Culloden with a severe contusion of the head, and in company with John Roy Stewart underwent in hiding some romantic adventures. The two were concealed first by the lady of the minister of Alvey, and they afterwards lay in a cave under a tree root in Glenmore. Finally, after some hairbreadth escapes, they found a means of fleeing to France. Hamilton spent part of his exile in Italy, but in 1749 the interest of friends procured his pardon, and he returned home. In the same year, by the death of his elder brother, he inherited the family estates in Ayrshire. But he did not live long to enjoy these. The hardships which he had undergone had undermined his health, his constitution gave way, and though he again went abroad, he died of consumption at Lyons on March 25, 1754. His body was brought home and buried in the Abbey Church at Holyrood.
A collection of Hamilton's verses — Poems on Several Occasions — was printed without the author's knowledge by the Foulises at Glasgow in 1748, the preface to the edition being written by the celebrated Adam Smith. In 1760 the volume was reprinted with the author's corrections, at Edinburgh. Hamilton's compositions are also included in Chalmers's ponderous collection, in the Chiswick Press series, and in an edition of the works of Allan Ramsay and his contemporaries edited by Charles Mackay. But the most complete is that edited by James Paterson at Edinburgh in 1850.
Hamilton's poems include a considerable number of imitations and translations of such classics as Homer, Virgil, and Horace, more or less happily turned, a number also of odes, songs, and society verse in the tone of his time. Besides these fashionable productions, he essayed the mock-heroic in a piece, The Maid of Gallowshiels, but owing to his lack of humour the effort falls flat. His single title to remembrance lies in his beautiful ballad composition, The Braes of Yarrow, published in the Orpheus Caledonius when he was no more than twenty-one. The poem forms a kind of sequel to the old Border ballad of The Dowie Dens o' Yarrow. Its first verse is ancient. A song by Allan Ramsay, beginning with the same verse, appears in Johnson's Musical Museum. But Hamilton's ballad far outstrips the composition of his contemporary. It stands out, one of the few genuine inheritors of the spirit of ancient folksong. Sir George Douglas has recalled the fact that "with its yearning pathos, its fresh touches of nature, its tragic passion, and its haunting tune, it has the distinction of having served as a source of inspiration to Wordsworth." And Professor Veitch has said of it, "It breathes the soul of the place, and is so permeated by the spirit of its history and traditions, that when all the other writings of the author shall have fallen into oblivion there will still be a nook in memory and a place in men's hearts for The Braes of Yarrow."