He was the son of James Johnstone, 1st Earl of Annandale and Hartfell and Henrietta Douglas.
He succeeded to the Earldom of Annandale and Hartfell on the death of his father in 1672.
He was a friend of Monmouth and nominally supported Revolution, but joined "The Club" of Jacobite malcontents and was imprisoned in connection with the Montgomery plot.
He opposed the Union, but later served as a Scottish representative peer from 1709 to 1713.
William was married twice: first on 1 January 1682 to Sophia Fairholme, daughter of John Fairholme of Craigiehall, and second on 20 November 1718 to Charlotte Van Lore Bempde, daughter of John Vanden Bempde of Hackness.