The second government of Mariano Rajoy was formed on 4 November 2016, following the latter's election as prime minister of Spain by the Congress of Deputies on 29 October and his swearing-in on 31 October, as a result of the People's Party (PP) emerging as the largest parliamentary force at the 2016 Spanish general election. It succeeded the first Rajoy government and was the government of Spain from 4 November 2016 to 7 June 2018, a total of 580 days, or 1 year, 7 months and 3 days.