Lang was born in 1844 in Selkirk, Scottish Borders. He was the eldest of the eight children born to John Lang, the town clerk of Selkirk, and his wife Jane Plenderleath Sellar, who was the daughter of Patrick Sellar, factor to the first Duke of Sutherland. On 17 April 1875, he married Leonora Blanche Alleyne, youngest daughter of C. T. Alleyne of Clifton and Barbados. She was (or should have been) variously credited as author, collaborator, or translator of Lang's Color/Rainbow Fairy Books which he edited.
He was educated at Selkirk Grammar School, Loretto School, and the Edinburgh Academy, as well as the University of St Andrews and Balliol College, Oxford, where he took a first class in the final classical schools in 1868, becoming a fellow and subsequently honorary fellow of Merton College. He soon made a reputation as one of the most able and versatile writers of the day as a journalist, poet, critic, and historian. He was a member of the Order of the White Rose, a Neo-Jacobite society which attracted many writers and artists in the 1890s and 1900s. In 1906, he was elected FBA.
He died of angina pectoris on 20 July 1912 at the Tor-na-Coille Hotel in Banchory, Banchory, survived by his wife. He was buried in the cathedral precincts at St Andrews, where a monument can be visited in the south-east corner of the 19th century section.