Pitcairn was born in Burntisland, Fife, in 1752. His father, John Pitcairn (1722–75), was a major in the Royal Marines who commanded the British advance party at the Battle of Lexington that fired the "shot heard round the world", and died from wounds after the Battle of Bunker Hill in 1775. His paternal grandfather, David Pitcairn, was a clergyman at Dysart, Fife, and his paternal grandmother Katherine was the daughter of William Hamilton. His mother Elizabeth (1724–1809) was the daughter of Robert Dalrymple. His uncle William Pitcairn (1712–91) was a doctor at St Bartholomew's Hospital in London.