Alex Salmond's term as first minister of Scotland began on 17 May 2007 when he was formally sworn into office at the Court of Session. It followed his Scottish National Party's win at the 2007 Scottish Parliament election, where his party defeated the incumbent Labour Party by just one seat. Salmond's term ended on 18 November 2014, following his resignation in the aftermath of the Yes campaign's defeat in the 2014 Scottish independence referendum.