The son of William Guthrie Robertson McGregor and Agnes McGregor (née Reid), McGregor was educated at Inverurie Academy, Scarborough High School, and Queen's College, Oxford, where he held the Hastings Scholarship and graduated BA in 1951, BCL in 1952, MA in 1955, and DCL in 1983.
Before going up to Oxford, McGregor served as a Flying Officer in the Royal Air Force for two years, from 1946 to 1948.