From the age of sixteen Gray worked in a bank as an apprentice clerk, but found the work ‘utterly repugnant’ and studied literature and art in his spare time. After ten years as a freelance art critic he was appointed the first curator of the Scottish National Portrait Gallery in 1884. His main task was the systematic cataloguing of the national collection of portraits, something for which he received great praise. His numerous publications include a book on George Manson, a Scottish artist whose self-portrait is thought to be the right-most painting in the background, the other two depicting Burns and Scott. Friendly but somewhat reserved in character, Gray lived in Edinburgh all his life and never married. After his premature death he left nearly all he owned to the Portrait Gallery.