Donald Petrie was born in the parish of Edinkillie, Morayshire, Scotland, on 7 September 1846, the son of Alexander Petrie, a farmer, and his wife, Isabel Morrison. Donald was educated at Aberdeen Grammar School, and later attended the University of Aberdeen, graduating MA in 1867. He taught briefly at the Glasgow Free Church Training College and the Glasgow Academy and then, in 1867, took up a position at Scotch College, Melbourne, Australia, where his uncle, Alexander Morrison, was principal.
Over the next six years Petrie gained a reputation as a sound and scholarly teacher of classics, also making an impression with his 'tall and commanding' appearance and 'quiet and gentlemanly' demeanour. In October 1873 he applied successfully for the position of inspector of schools with the provincial government in Otago, New Zealand. He published and revised textbooks on geography between 1878 and 1886 and was said to have revolutionised the teaching of infants. He was re-appointed an inspector when education became a national responsibility in 1877, and from 1894 until his retirement in 1910 was chief inspector of schools to the Auckland Education Board.
Petrie had long been interested in botany, geology and chemistry, and in February 1874 he became a member of the Otago Institute. Fellow members G. M. Thomson and A. C. Purdie, both founding members of the Dunedin Field Naturalist Club, encouraged his interest in botany. Probably, too, they gave him the scientific training he had previously lacked. In October 1878 he presented his first paper to the Otago Institute; he was to publish over 60 papers up to 1925.
The duties of a school inspector allowed Petrie many opportunities as he travelled throughout Otago for collecting botanical specimens, especially in the dry areas of Central Otago. He invariably took his collecting-press and searched constantly for new plants by the roadside. In his spare time he scaled mountains that, botanically, had been explored inadequately or not at all.
Petrie travelled widely in his search for plants. In 1880 he and Thomson were the first to carry out the systematic collection of flora on Stewart Island. They hired a cutter that enabled them to dredge areas of Paterson Inlet and Port Pegasus, and collected 201 specimens in a limited time and in difficult country. Petrie made collecting trips with Leonard Cockayne to Westland and Canterbury in 1893, and with James Adams in 1897 to Hicks Bay and Hikurangi Mountain. In 1907 and 1908 he visited the Tararua Range with B. C. Aston, and in 1913 joined P. G. Morgan's party on the geological survey of the Westport district. Cockayne spoke of his thoroughness as a collector: during one of their trips 'he looked neither to right nor left, but steadily gazed at the carpet of plants hour by hour, pausing only to collect those which were new to him or which he wished to examine'. Petrie continued searching for plants until a year before his death.
Most of Petrie's papers are descriptions of plants previously unknown, amounting to about 180 species or varieties. (An exception is his paper of 1896 listing 760 species of flowering plant indigenous to Otago.) The majority of his species identifications have proved to be correct although some were established without sufficiently careful experimentation. He became an authority on Gramineae (grasses) and Cyperaceae (sedges), in particular the genera Carex and Uncinia because of his love for working with groups distinguished only by small differences. In 1912 he reported to the Department of Agriculture on methods of re-grassing the depleted pastures of Otago, and in 1917 he received a grant for the exploration of the grasses of southern Nelson.
Petrie was associated with several scientific institutions and received high honours. He was elected a fellow of the Linnean Society of London in 1886, and was president of the Auckland Institute in 1896 and vice president in 1897–98. He served as a council member of the New Zealand Institute for many years, was a member of its board of governors from 1908 to 1917, president in 1915, and one of its 20 original fellows in 1919. In 1924 he was awarded the Hector Memorial Medal and Prize in recognition of his contribution to establishing a more accurate knowledge of New Zealand's flora. Petrie deplored the failure of any New Zealand museum to establish a comprehensive collection of native and introduced plants; in 1922 he gave the Dominion Museum his herbarium of some 1,800 species from nearly 15,000 localities.
Donald Petrie had married Mary Cherrett at St Paul's Cathedral Church, Thorndon, on 27 June 1882; they had two sons and one daughter. After the family's move to Auckland, he purchased farmland at Waingaro near Raglan for his sons; he sold this in 1919 and bought the property Te Whio at Whangaripo near Wellsford. Petrie died at his home in Auckland on 1 September 1925 and was buried at St Mark's cemetery, Remuera. Mary Petrie died at Auckland on 20 March 1953.