Elder was the eldest son of Elizabeth and William Elder of Loaning. The exact date of his birth is not known, but he was baptised on 7 October 1737. Elder held the office of chief magistrate of Edinburgh for three different periods, viz. 1788-90, 1792–1794, and 1796-8. During his second term of office he took an active part in suppressing the meetings of the Friends of the People, and without any military aid he broke up the meeting of the British Convention held at Edinburgh on 5 December 1793, and took ten or twelve of the principal members prisoners. In Edinburgh his shop was on the Royal Mile opposite the Tron Kirk at his house was at 5 Princes Street. His house was demolished around 1900. On the formation of the Royal Edinburgh Volunteers in the summer of 1794 he became their first Colonel in Chief, and on 9 September 1794 was voted a piece of silver plate by the town council "for his spirited and prudent conduct while in office, and especially during the late commotions". In 1795 Elder was appointed Postmaster General for Scotland. Through his exertions the scheme for rebuilding the college was successfully matured. The foundation-stone of the new buildings was laid during his first mayoralty on 16 Nov. 1789, but they were not completed until after his death. In Edinburgh in later life he lived in a then new townhouse at 85 Princes Street in Edinburgh's First Town. He died at Forneth House, in the parish of Clunie in northern Perthshire, on 29 May 1799, aged 66. He was buried in the old churchyard in Clunie on 2 June.
Family
In 1765 Elder married Emilia Husband, the eldest daughter of Paul Husband of Logie, an Edinburgh merchant. They had four daughters and one son. His eldest daughter, Isabella, married George Husband Baird on 9 August 1792, who later became the Principal of the University of Edinburgh.
Artistic recognition
Elder's portrait, by Henry Raeburn, which was painted in 1797 at the request of the principal and professors of the university, is preserved in the court room of the university, It has been engraved by Richard Earlom. A duplicate of this portrait was exhibited at the Raebum exhibition in Edinburgh in 1876. Two etchings of Elder by Kay will be found in Kay's 'Original Portraits'. His cameo, by James Tassie, is in the Scottish National Portrait Gallery in Edinburgh.