Montgomery was born at Macbie Hill in Peeblesshire in October 1721, the second son of William Montgomery, Sheriff-Depute of Peeblesshire, of Coldcoat or Macbie Hill, Peeblesshire. His mother was Barbara Rutherford, daughter of Robert Rutherford of Bowland, Stow, Midlothian. In Edinburgh he resided at Queensberry House on the Royal Mile and was its last resident as a private house. Here he famously had a black servant named "Hannibal". After schooling at the parish school at West Linton, Montgomery studied law at the University of Edinburgh, and was called to the Scottish bar on 19 February 1743. In 1748, after heritable jurisdictions had been abolished, he was appointed the first sheriff of Peebles under the new system. On 30 April 1760, thanks to the influence of his friend Robert Dundas, then newly appointed lord president, he succeeded Sir Thomas Miller, Lord Glenlee as Solicitor General for Scotland jointly with Francis Garden. In 1764, he became sole solicitor-general, and in 1766 Lord Advocate in succession to Miller, to whose parliamentary seat for the Dumfries Burghs he succeeded also. But at the general election of 1768, Montgomery was returned for Peeblesshire, a seat which he retained till he was raised to the bench. A learned lawyer and an improving landlord, he was peculiarly fitted to deal with the question of entails, which had now become pressing, owing to the extent to which details fettered the practical management of land. The existing statute was Sir George Mackenzie's Act of 1685, and since it passed 485 deeds of entail had been registered under it. The public demanded a reform ; the Faculty of Advocates had passed resolutions approving it. Montgomery accordingly introduced a measure in March 1770, which passed into law and considerably enlarged the powers of the heir of an entail in respect of leasing and improving the entailed lands, and even provided for the exchange of land in spite of an entail. Though he remained in parliament, Montgomery took little further interest in its proceedings after the passage of his bill. In June 1775, he was created Lord Chief Baron of the Scottish Exchequer, and in 1781 he was elected fellow of the Society of Antiquaries of Scotland; he resigned his judgeship in April 1801. In July 1801, he was created a Baronet. Montgomery was, like his father, skilled in farming, and in 1763 bought a half-reclaimed estate of Lord Islay's in Peeblesshire, originally called Blair Bog, but afterwards 'The Whim,' which eventually became his favourite residence. In 1767, he bought for £40,000 Stanhope and Stobo with its feudal barony in Peeblesshire, part of the estates of Sir David Murray, which had been confiscated for their owner's complicity in the prebellion of 1745. He thenceforward chiefly resided in the country, where his good methods of farming and the improvements which he promoted, notably the Peebles and Edinburgh road in 1770, gained for him the title of 'The Father of the County.' Montgomery died at Stobo on 2 April 1803 and is buried in Stobo churchyard.
Family
Montgomery married Margaret Scot, daughter and heiress of Robert Scot of Killearn, Stirlingshire. Montgomery was succeeded in his baronetcy by James, his second son, afterwards Lord Advocate, his first-born son, William, a lieutenant-colonel in the 43rd foot, having predeceased him. Montgomery and his wife, Margaret Scott, are buried in a walled-off part of the cemetery at Stobo Kirk near Peebles, with an unusual wall lining of yew hedge. His home had been the nearby Stobo Castle, which he purchased in 1767 for the sum of £40,500. Montgomery was grandfather to James Francis Montgomery.