Barclay was born at Gordonstoun in Moray, Scotland. His father David Barclay, first laird of Ury, had served under Gustavus Adolphus, and pursued a somewhat tortuous course through the troubles of the Civil Wars. His mother was Katherine Gordon (1620–1663), the daughter of Sir Robert Gordon, 1st Baronet of Gordonstoun. He was the eldest of five children.