MacDonald was born at Gregory Place, Lossiemouth, Morayshire, Scotland, the illegitimate son of John MacDonald, a farm labourer, and Anne Ramsay, a housemaid. Registered at birth as James McDonald (sic) Ramsay, he was known as Jaimie MacDonald. Illegitimacy could be a serious handicap in 19th century Presbyterian Scotland, but in the north and northeast farming communities, this was less of a problem; in 1868, a report of the Royal Commission on the Employment of Children, Young Persons and Women in Agriculture noted that the illegitimacy rate was around 15%, meaning that nearly every sixth person was born out of wedlock. MacDonald's mother had worked as a domestic servant at Claydale farm, near Alves, where his father was also employed. They were to have been married, but the wedding never took place, either because the couple quarrelled and chose not to marry, or because Anne's mother, Isabella Ramsay, stepped in to prevent her daughter from marrying a man she deemed unsuitable.