Following the SNP's victory in the 2007 Scottish Parliament election, MacAskill was appointed as Cabinet Secretary for Justice in the Scottish Government. In this role, he oversaw the controversial transfer of convicted terrorist Abdelbaset al-Megrahi to his native Libya. MacAskill left office in November 2014 in the Cabinet reshuffle which followed the appointment of Nicola Sturgeon as First Minister of Scotland. After standing down at the 2016 Scottish Parliament election, MacAskill was elected as Member of Parliament for East Lothian at the 2019 general election, gaining the previously Labour-held seat from Martin Whitfield.