Gray spent his childhood in Dundee, and was educated at the High School of Dundee, going on to study maths and economics at Edinburgh University. This was followed by periods of study at Göttingen University and at the Sorbonne in Paris. During the First World War he worked in the civil service, employing his linguistic skills to produce anti-German propaganda.
In 1921 he was appointed professor of Political Economy at Aberdeen University, and whilst there he published one of his most important economic works,
The Development of Economic Doctrine, in 1931. In 1934 he took up the equivalent post at Edinburgh University, which he held until his retirement in 1956. During the Second World War he returned to work for the civil service, returning to his professorship at Edinburgh after the war. In 1948 he published a study of the life and doctrines of Adam Smith. He was elected a Fellow of the Royal Society of Edinburgh in 1942.
In addition to his economic writings, Gray was an active composer and translator of poetry. His work consisted of original poems written in English, and translations of the folk and ballad poetry of Germany and Denmark into Scots. Some of his work featured in
Northern Numbers, a periodical founded and edited by Hugh MacDiarmid. Of his English poems,
Scotland is internationally renowned, the third stanza being frequently quoted. This quote features on the Canongate Wall at the new Scottish Parliament building:
This is my country,The land that begat me.These windy spacesAre surely my own.And those who toil hereIn the sweat of their facesAre flesh of my flesh,And bone of my bone.
His translations into Scots constitute the greater part of his work, and is the main basis for his reputation. His translations include a collection of ballads,
Arrows, from German, and
Historical Ballads of Denmark and
Four and Forty from Danish. He translated many German poets, including von Kotzebue, Müller, Uhland, Herder but, above all, Heine.