He was born on 8 July 1829, the son of John Ferguson, a pawnbroker, and his wife, Elisabeth Cochran.
He was educated at the Free Church Training College (Edinburgh). He studied natural philosophy in the university of Edinburgh and, after, in the university of Heidelberg where he was awarded with a PhD in 1855 tutored by Robert Bunsen.[1] From 1858 till his retirement in 1898 he was headmaster in the Edinburgh Institute (now known as Stewart's Melville College), where he taught among others William Cunningham.[2] He lost a leg in a school laboratory explosion in 1897.