Sir William Stirling was the son of Archibald Stirling of Keir, and Elizabeth, elder daughter of Sir John Maxwell, 7th Baronet of Pollok. He was educated at Trinity College, Cambridge, taking his B.A. in 1839, and M.A. in 1843. He was Member of Parliament for Perthshire 1852 1868, and 1874 1878. He married, firstly, 26 April 1865, Anne Maria Leslie Melville, third daughter of the 8th Earl of Leven, and secondly, 1 March 1877, Caroline Sheridan, widow of George Chapple Norton. In 1865, on the death of the 8th baronet, he inherited the baronetcy of Maxwell of Pollok under the special remainder in the new creation of 1707, which is to heirs general of the body. In the following year he assumed the additional name and arms of Maxwell. A distinguished art collector and critic, particularly of Spanish painting, he was made a Knight of the Thistle in 1876.