He become assistant surgeon in the East India Company's service on 17 June 1788, and on his arrival in India was appointed garrison surgeon of Chingleput. On 17 October 1794 he was promoted to the grade of surgeon, having been two years previously transferred to Ganjam. In 1810 he was appointed superintending surgeon, the court of directors having approved his motives in drawing up a scheme to improve the health of the troops in India, whilst rejecting the plan proposed. He was named superintending surgeon of the southern division of the army (Madras) in 1814, and two years later the sum of six hundred guineas was awarded to him as a mark of the estimation in which his services were held by the court of directors.
In 1815 he resigned, having served twenty-seven years apparently without any furlough, and returned to England in the autumn of that year. During his residence in India he seems to have published the joint report mentioned below, a ‘Treatise upon Edible Vegetables,’ and the ‘Materia Medica of Hindostan.’ After his return he occupied himself by launching out into different branches of literature, as shown by the appended list of works. In 1835 he refers to himself as being in the ‘vale of years,’ the book being dedicated to his wife.
He was elected a Fellow of the Royal Society of Edinburgh in 1829.
He was knighted in 1835.
He died in London on 29 April 1837.
He published the following works:
- Materia Medica of Hindostan, Madras, 1813.
- Materia Indica; or Some Account of those Articles which are employed by the Hindoos and other Eastern Nations in their Medicine, Arts, and Agriculture, London, 1826, 2 vols. (an amended edition of the above.)
- Clemenza, or the Tuscan Orphan; a tragic drama in five acts, Bath, 1822, 2nd edition, 1823.
- Observations on the Cholera Morbus of India, London, 1825. (A rejoinder to this tract was published by James Morison, the hygeist, in the same year.)
- Medical Observations, forming pp. 353–367 of vol. iii. of Hugh Murray's Historical and Descriptive Account of British India 1832, (vols. vi.–viii. in the Edinburgh Cabinet Library); new edition in 1844,
- An Historical Sketch of the Introduction of Christianity into India, Edinburgh, 1835, with A. Smith and M. Christy.
- Report on the Causes of the Epidemical Fever which prevailed in the Provinces of Coimbatore, Madeira, Dinigal, and Tinivelly, in 1809–10–11, London, 1816.
- This article incorporates text from a publication now in the public domain: "Ainslie, Whitelaw". Dictionary of National Biography. London: Smith, Elder & Co. 1885–1900.