Leaving office in a cabinet reshuffle in 2013, Yıldırım ran as the AKP candidate for Mayor of İzmir in the 2014 local elections but lost to the incumbent Republican People's Party (CHP) candidate Aziz Kocaoğlu. He was appointed as special advisor to Erdoğan in June 2014 and left Parliament in the June 2015 general election due to the AKP's three-term rule for its sitting MPs. He was re-appointed as Transport Minister by Prime Minister Ahmet Davutoğlu after being reelected to Parliament in the November 2015 general election. Following Davutoğlu's resignation as party leader due to a breakdown in relations with President Erdoğan on 5 May 2016, Yıldırım was announced as the AKP's next leader by the Central Executive Committee on 19 May and was elected unopposed during the party's 2nd Extraordinary Congress on 22 May 2016. He formed the country's 65th government and became Prime Minister on 24 May 2016. Factions of the Turkish Army in discontent with his policies attempted to oust him in a failed military coup d'état attempt on 15 July 2016.