He was educated at the parish school. He became the inspector of the bank"s branches and during his frequent inspections he studied the local birds.
At the age of fifteen he became an apprentice in the branch of the British Linen Company Bank. Five years afterwards he joined the head office of the City of Glasgow Bank. From early years he had been addicted to the study of natural history.
He soon adopted ornithology as his speciality.
The note-books and their illustrations by his skilful pencil, formed the basis of his ‘Birds of the West of Scotland,’ published in 1871. In 1851 Gray was one of the founders of the Natural History Society of Glasgow.
He contributed to the ‘Proceedings’ of that body, was its treasurer from 1854 to 1856, and was elected its secretary in 1858, a post which he resigned in 1871, when he was appointed agent of the branch of the City of Glasgow Bank in Saint Vincent Street, Glasgow. She formed extensive geological collections illustrative of the fossils of the silurian rocks of the south of Scotland during the family"s annual holidays at Girwen.
In March 1874 Gray entered the service of the Bank of Scotland as superintendent of branches,, and eight years later he became cashier there, an appointment which he retained during the rest of his life.
In he again devoted himself to the interests of science. In 1882 he was elected vice-president of the Royal Society there. But it was in connection with the Royal Physical Society that he made his main influence.
This society, one of the oldest scientific bodies in, had ‘fallen into one of its periodic fits of depression,’ when, in 1877, Gray accepted its secretaryship.
He entered on his duties with great energy, and, by his courtesy and singular charm of manner not less than by his power of organisation and his excellent business faculty, he was successful in introducing needed reforms, in attracting new members and inspiriting old ones, and, finally, in placing the society upon a satisfactory footing as an active scientific body, issuing printed ‘Proceedings.’ At the time of his death, which occurred suddenly in on 18 February 1887, Gray was engaged, in conjunction with William Evans, upon a volume dealing with the birds of the east coast of Scotland.