He was born at Torwoodlee Mains, a farm in the parish of Stow in the Scottish Borders, on 22 November 1779. He attended school in Clovenfords.
He entered the University of Edinburgh in 1794, studying Medicine, supporting himself by teaching. He graduated M.D. in 1801. After serving for a short time as a surgeon/apothecary in an army hospital service he started studying law. But in 1804 he became amanuensis (literary assistant) to the Rev. Alexander Carlyle in Inveresk (who gave him the manuscript of his autobiography on his death in 1805).
Lee was licensed as a preacher in 1807, and after acting for a few months as pastor of a Presbyterian chapel in London he was ordained as minister of Peebles. In 1812 he was appointed Professor of Church History at St Mary's College, St Andrews, and was there chosen rector of the college. In 1820 he became Professor of Moral Philosophy in King's College, Aberdeen, but his lectures there were mostly delivered by a deputy. He continued to lecture in St Andrews, intending to travel regularly between the two, however, he had a change of heart following a near-fatal accident when his stage-coach overturned en route to Aberdeen.
Therefore, in 1821 Lee resigned both professorships and, aided by the granting of a Doctor of Divinity from St Andrews University, accepted a position as minister of the Canongate Church in Edinburgh. He was elected a Fellow of the Royal Society of Edinburgh in 1822, his proposer being George Forbes. He served as their Literary Councillor 1823-6 and as the Vice-President 1842-1859.
In 1825 he was translated from the Canongate to Lady Yester's Church, and was appointed a chaplain in ordinary to the king in 1830. He was made principal clerk of the General Assembly in 1827, but unsuccessfully contested the moderatorship with Thomas Chalmers in 1832. In 1834 he became minister of the old church of St. Giles's, Edinburgh, in 1837 Principal of the United College, St Andrews, and in 1840 Dean of the Chapel Royal, Stirling. In 1840, also, he was elected Principal of the University of Edinburgh.
When the Disruption of 1843 took place, Lee remained faithful to the established Church of Scotland. He undertook to conduct the divinity class, and was shortly afterwards was made Professor of Divinity in succession to Thomas Chalmers, holding this office concurrently with his principalship. He was elected Moderator of the General Assembly of the Church of Scotland in 1844.
Lee died in his lodgings at New College at the University of Edinburgh on 2 May 1859. He is buried in the south-west section of St Cuthberts Churchyard in Edinburgh, next to the Balfour Paul monument.
Lee was married to Rose Masson (1792-1898).
Lee's children included Robert Lee, Lord Lee (1830-1890) and Dr Thomas Masson Lee IMS.
Lee was accomplished in almost every branch of knowledge, and in Scottish literary and ecclesiastical history had very detailed information. He collected a library of twenty thousand volumes. He was caricatured by John Hill Burton in the Book Hunter as Archdeacon Meadows the bibliomaniac, who would buy a book of which he had several copies already, and then, not being able to find any of his copies, would have to borrow the same book from a friend for reference.
Lee's doctoral thesis was De viribus animi in corpus agentibus. His main works were:Six sermons, 1829.
Memorials of the Bible Society in Scotland, 1829.
Dr. Lee's Refutation of Charges brought against him by the Rev. Dr. Chalmers, in reference to the questions on Church Extension and University Education, 1837.
Lectures on the History of the Church of Scotland, 1860.
The University of Edinburgh from 1583 to 1839, 1884.
Lee also edited tracts by David Fergusson for the Bannatyne Club in 1860.