Robert Ainslie (1766–1838) was a Scottish lawyer, and one of Robert Burns's long-term friends from his Edinburgh days. He was probably the closest confidant of Burns, whom he met first at a Masonic or Crochallan Fencibles event. Ainslie accompanied the poet on the first part of his Border Tour. Robert's father, also Robert, was a lawyer a bailie at Duns and a land-steward on Lord Douglas's Berwickshire estates. Robert married Jean Cunningham on 22 December 1798.