Mercer was born on January 17, 1725, at Pitsligo Kirk, the family farm in Aberdeenshire, Scotland. His parents were William Mercer, a Presbyterian minister, and Ann Monro Mercer. By 1744, he had obtained a medical degree from the University of Aberdeen. Mercer and his family were Jacobites, meaning that they supported the restoration of the Stuarts to the English throne. The Stuart king James II, a Catholic, had been deposed in 1688 by the Dutch Protestant William III and his wife, Mary, who was King James’s daughter. Queen Anne, another of James’s children, ruled from 1702 to 1707, after which the Hanoverian kings succeeded to the throne. When Charles Edward Stuart, Anne’s brother, arrived in western Scotland, in July 1744, Mercer promptly joined the cause, fighting with “Bonnie Prince Charlie” at Culloden on April 16, 1746.