Born in Glasgow, Scotland, young Rainy was intended for his father's profession, but he was caught by the evangelical fervour of the Disruption movement, and after studying for the Free Church he became a minister, first in Aberdeenshire and then in Edinburgh, till in 1862 he was elected professor of Church history in the theological seminary, New College, a post he only resigned in 1900. In 1874 he was made principal of the college and was subsequently known as Principal Rainy. To this day, the dining Hall in New College is called the Rainy Hall.
He had come to the front as a champion of the liberal party in the Union controversy within the Free Church, and in combating Dean Stanley's Broad Church views in the interests of Scotch evangelicism; and about 1875 he became the undisputed leader of the Free Church. He guided it through the controversies as to Robertson Smith's heresies, as to the use of hymns and instrumental music, and as to the Declaratory Act, brought to a successful issue the union of the Free and United Presbyterian Churches, and threw the weight of the united church on the side of freedom of Biblical criticism.
He was the first moderator of the General Assembly of the United Free Church of Scotland, having previously been moderator of the Free General Assembly. Though not a great scholar he was eminent as an ecclesiastical statesman, and his influence was far-reaching. After the strain of the fight with the so-called "Wee Frees" in 1904-5 his health broke down, and he went to Australia for recovery, but died at Melbourne on 22 December 1906.
See Lives by Patrick Carnegie Simpson (1909) and R Mackintosh (1907).