MacGillivray was born in Aberdeen, the son of ornithologist William MacGillivray. He took part in three of the Royal Navy's surveying voyages in the Pacific. In 1842 he sailed as naturalist on board HMS Fly, despatched to survey the Torres Strait, New Guinea, and the east coast of Australia, returning to England in 1846.
In the same year he was appointed as naturalist on the voyages of HMS Rattlesnake (Captain Owen Stanley), collecting in Australian waters at Port Curtis, Rockingham Bay, Port Molle, Cape York, Gould Island, Lizard Island and Moreton Island in Queensland, Port Essington (Northern Territory) and visiting Sydney (New South Wales) on several occasions. The expedition was in Hobart, Tasmania, in June 1847 and also surveyed in Bass Strait, and on the southern coast of New Guinea and the Louisiade Archipelago. On this series of voyages his most notable achievement was to make records of the aboriginal languages of the peoples he encountered. His account of the voyages was published in London.
In 1852 he deserted his sick wife and his children in London, and sailed for Australia. T.H. Huxley found his consumptive wife down to her last shilling, and raised £50 to send her and the children back to Australia where her parents could look after her. She died two weeks from Sydney (Desmond 1994 p217).
MacGillivray's journey on HMS Herald was also doomed to failure. The ship visited Lord Howe Island, New South Wales, Dirk Hartog Island and Shark Bay, Western Australia. On this expedition he was accompanied by Scots naturalist William Grant Milne. MacGillivray left the voyage early in 1855, having been dismissed by the captain Henry Mangles Denham. He had become a hopeless drunkard, and when he died, alone in a squalid hotel room, the records noted 'mother and father unknown' (Desmond 1994).
MacGillivray died in Sydney, New South Wales, on 6 June 1867. He is commemorated in the name of the Fiji petrel Pseudobulweria macgillivrayi. He also collected a specimen of venomous elapid snake on the northeastern coast of Australia. It was described by zoologist Albert Günther in 1858 as Glyphodon tristis but it is now called Furina tristis. In the late 19th century it was known as MacGillivray's snake  but this name has now fallen into disuse and it is now called either the brown-headed snake or the grey-naped snake.
- Desmond, Adrian. Huxley: the Devil's Disciple. Joseph, London 1994.
- MacGillivray, John. Narrative of the voyage of HMS Rattlesnake. 2 vols, Boone, London 1852.
- Orchard A.E. 'A History of Systematic Botany in Australia', in Flora of Australia Vol 1, 2nd ed, ABRS, 1999.
- Krefft, G. 1869 The Snakes of Australia; An illustrated and descriptive catalogue of all the known species. Thomas Richards, Sydney pp.viii+100.
- Waite, E.R. 1898 A Popular Account of Australian Snakes: with a complete list of the species and an introduction to their habits and organization. Thomas Shine, Sydney pp.71.
- IPNI. J.MacGill.