John MacGregor was born, probably in 1849 or 1850, at Aberfeldy, Perthshire, Scotland, the son of James MacGregor, a stonemason, and his wife, Isabella MacGregor. After receiving his primary education at the Breadalbane Academy, Perthshire, he enrolled at the University of Edinburgh, graduating MA in 1874. Later that year, he followed his brother Duncan to Dunedin, New Zealand, where, in 1875, he entered the office of Robert Stout and began studying law. He married Stout's sister, Jessie Smith Stout, at Dunedin on 6 November 1878. She died in 1890, leaving MacGregor with a young son, Thomas.
MacGregor was admitted a barrister and solicitor of the Supreme Court in 1876. He spent some months in Timaru before returning to Dunedin, where he went into partnership with Peter Duncan. MacGregor was highly regarded as a most capable lawyer of broad liberal principles. A man of culture and wide interests, he was a member of the Otago Education Board for 12 years, including two as chairman. He also played an active part in the affairs of the Otago District Law Society, serving as president in 1891 and 1910.
In 1892 MacGregor was appointed to the Legislative Council. He showed great force of character and independence of thought, supported by an uncommon mastery of constitutional and legal history and principles. A valuable member of the Council's Statutes Revision Committee, he supported the Council's right to amend the financial provisions of important policy measures such as the Government Advances to Settlers Act 1894 and the Land for Settlements Act 1894, and ably defended its actions in his pamphlet 'Money bills' and the powers of the Legislative Council relative thereto (1895). He was responsible for numerous reforms in legal matters, especially where the law failed to take account of common sense.
MacGregor's contribution to debates and his published articles and pamphlets give evidence of wide reading and a deep appreciation of political philosophy. He submitted to close analysis and pungent criticism the newly introduced system of compulsory industrial arbitration, and his pamphlets on the topic were widely sought after by students of labour law. He doubted the utility of trial by jury in civil cases, and advocated the adoption of a verdict of 10 out of 12 jurors in criminal cases. For MacGregor there was nothing sacrosanct about the common law: in his view principles of civil law adopted in Scotland and in many European countries contained valuable lessons for New Zealand law.
In the two pieces of legislation for which MacGregor was chiefly responsible he showed broad human sympathies. The Legitimation Act 1894 legitimated children on the subsequent marriage of their parents, and the Divorce Act 1898 extended the grounds on which women were entitled to petition for divorce; wives as well as husbands could now cite adultery as a reason, and desertion was made a ground for divorce rather than merely for judicial separation. MacGregor defended his position in Marriage and divorce: the ecclesiastical and the rationalistic conception of marriage contrasted. Social questions, he wrote, should be considered apart from 'the fetters of theological dogmas and superstitions', and he claimed that there was no reason why laws of ecclesiastical origin should not be considered capable of improvement in the same way as other laws. The bill was passed only after much strenuous opposition.
Love of liberty and reason underlay all that MacGregor said and wrote, and his arguments were marshalled in clear and forceful prose. In Our only true democrat (1894) he vehemently attacked James Gibb, minister of First Church of Otago, Dunedin, for his advocacy of a referendum on the question of Bible reading in schools. Not only was the proposal an interference in the sphere of conscience and religion, but the mere will of the majority could never make injustice just.
Similar principles motivated MacGregor's writing on political matters. In Parliamentary government in New Zealand (1896), he attacked government by party, a system the evils of which were so great that representative government was becoming discredited. Parliament did not freely discuss matters but merely obeyed the will of the executive; it had become a 'mask for despotism'. His remedy for the situation was an elected executive with members directly responsible to the legislature and liable to censure or dismissal.
MacGregor returned to the attack in Liberalism true and false (1899), a trenchant criticism of what he saw as the degeneration of liberalism under Richard Seddon. Seddon had reduced the Liberal party to 'a synonym for corruption'. Legislation was designed to advance sectional rather than national interests; constituencies were bribed by public money for private works; Seddon had openly stated that Liberals should have preference in government appointments; and there was open interference in candidate selection. Older Liberals regarded the modern party as 'the triumph of a mere numerical majority, consisting of the blind and mercenary followers of self-seeking demagogues'. In addition to the elective executive, MacGregor, whose earlier unicameralist views had changed when he saw the evils of unrestrained executive government, now sought to make the Legislative Council an elective body.
It is scarcely surprising that MacGregor declined to make himself available for reappointment to the Council in 1899 when he believed that this might be conditional on supporting the views of the government. After campaigning for the opposition in 1899, he returned to the law and took little part in politics; he did, however, help to write the opposition's election programme in 1905. He was subsequently appointed to the Legislative Council in 1914, partly to help ensure the passage of the Legislative Council Bill; this provided for the upper house to be elected on a system of proportional representation, and had twice been rejected by the Council. MacGregor retired from his legal practice in 1930 and from the Council in 1935.
A photograph of John MacGregor in old age shows him with a full head of white hair, a neatly trimmed beard and a calm and steady gaze. He had been a lover of music, and even in old age was known to sing patriotic Scottish songs in a fine tenor voice. He died at Dunedin on 25 November 1936. Sound in judgement, compelling in argument, staunch in friendship, he was held in genuine affection and respect by all his colleagues in the Legislative Council and in the legal profession.