Tomás mac Ailein, sometimes known as Thomas of Galloway, was an illegitimate son of Alan of Galloway (c. 1175–1234), Constable of Scotland and the last Mac Fearghusa lord of Galloway. After the death of his father, who left no legitimate sons, King Alexander II of Scotland planned to divide the lordship between the husbands of Alan's three daughters.
Thomas, along with his associate Gille Ruadh, led an unsuccessful rebellion against the king, with the aim of maintaining Galloway's status as an independent sub-kingdom.