Later life
He married in 1883 to Mary Jane, daughter of Levuka (Fiji) harbourmaster Captain Robert and Annie Cocks; who survived him with one son and three daughters. They met when he was the Administrator of British New Guinea. She was reported to have been the first Caucasian female born in Fiji. Two of the daughters were given to be born in Fiji. Lady MacGregor had nearly lost her life to fever on her first visit to her husband when he was the Governor of the Lagos Colony.
He was created a Companion of the Order of St Michael and St George in 1881, advanced to Knight Commander of the Order of St Michael and St George in 1889, made a Companion of the Order of the Bath in 1897, upgraded to Knight Grand Cross of the Order of St Michael and St George in 1907, and was made a privy councillor in 1914. He had the honorary degrees of DSc Cambridge, and LL.D. Aberdeen, Edinburgh, and Queensland.
In 1914 MacGregor retired and went to live on the estate 'Chapel-on-Leader' (near the River Leader, half-way between Lauder and Earlston, Berwickshire, Scotland).
MacGregor found his final year to be 'sorrowful', with the deaths of his son-in-law Admiral Sir Alfred Paget on 17 June 1918 of bronchitis, and Paget's wife and MacGregor's daughter Alpina 'Viti' Paget on 13 September 1918. After an operation for intestinal adhesions and gallstones MacGregor died on 3 July 1919, was cremated, and interred beside his parents in the churchyard of Towie, the village where he was born. Lady Mary MacGregor died in December 1919.
From his will, he bequeathed his ethnological and ornithological collections to the University of Aberdeen, and his banner from Saint Paul's Cathedral to the University of Queensland. In earlier years from his Papuan times, ethnological specimens were collected and presented to the Queensland Museum, bird specimens to the museum in Sydney, and a collection of flora to the botanical department in Melbourne; the latter indicated to have made the botanist Baron Von Mueller 'wildly enthusiastic'.
Two Australian suburbs are named after him: MacGregor, Brisbane, and Macgregor, Canberra.