After graduating as a Master of Arts from the Marischal College of Aberdeen, he was employed firstly as an apprentice engineer and thereafter in the "Ventilation Office" at the Houses of Parliament. From 1850 to 1867 he ran an engineering business in London, during which time he was granted many patents for his inventions in the field of railway engineering and steam engines. He then became a consulting engineer and patent agent. Among his early clients with whom he collaborated was the English philosopher-scientist Matthew Piers Watt Boulton (named after his grandfather, Matthew Boulton and his grandfather's business partner, James Watt). In 1868 M.P.W. Boulton and Imray jointly patented inventions related to "Propelling vessels". Some of Imray's works were also featured in the 1862 International Exhibition in London