Moray was the illegitimate son of James V of Scotland and Lady Margaret Erskine, daughter of John Erskine, 4th Earl of Mar.
After the return of his half-sister Queen Mary in 1561, he became her chief adviser. In 1562 he defeated a rebellion by George Gordon, Earl of Huntly, at Corrichie near Aberdeen. About this time Moray married Anne (d. 1583), daughter of William Keith, 1st Earl Marischal.
After Moray opposed Mary's marriage to Lord Darnley in 1565, he was declared an outlaw and took refuge in England. Returning to Scotland after the murder of David Rizzio, he was pardoned by the Queen. He contrived, however, to be away at the time of Darnley's assassination, and avoided the tangles of the marriage with Bothwell by going to France. After the abdication of Queen Mary at Lochleven, in July 1567, he was appointed regent of Scotland. When Mary escaped from Lochleven (May 2,1568), the Duke of Chatelherault and other Catholic nobles rallied to her standard, but Moray and the Protestant lords gathered their adherents, defeated her forces at the Battle of Langside, near Glasgow (May 13, 1568), and compelled her to flee to England.
Moray was assassinated in Linlithgow by Hamilton of Bothwellhaugh, a supporter of Mary.