On 27 October 2017 the Catalan Parliamentdeclared independence in a vote boycotted by opposition MPs. Almost immediately the Senate of Spain invoked article 155 of the constitution, dismissing President Carles Puigdemont and the Catalan government and imposing direct rule on Catalonia. The following day Spanish Prime MinisterMariano Rajoydissolved the Catalan Parliament and called for fresh regional elections on 21 December 2017. At the election Catalan secessionists retained a slim majority in the Catalan Parliament. On 22 January 2018 Catalan Parliament PresidentRoger Torrent officially proposed Puigdemont to be president. However, on 27 January 2018 the Constitutional Court of Spain ruled that Puigdemont, who had been living in exile since 30 October 2017, could not participate in any investiture debate via video conference or by getting another MP to read his speech and that he had to appear in person in parliament after receiving "prior judicial authorisation". The ruling effectively blocked the investiture of Puigdemont who faced arrest on charges rebellion, sedition and misuse of public funds if he returned to Spain. As a result Torrent announced on 30 January that Puigdemont's investiture vote would be postponed though he later insisted that Puigdemont "is and will be" the candidate for president. As the political impasse continued Puigdemont came under pressure to step aside. On 1 March 2018 Puigdemont announced that he was withdrawing his candidature in favour of jailed independence activist Jordi Sànchez. However, on 9 March 2018 Supreme Court judge Pablo Llarena refused permission for Sànchez to leave prison in order to attend the investiture debate. Sànchez ended his candidature on 21 March 2018. The secessionists hastily nominated Jordi Turull to be president. Turull was due to appear before the Supreme Court on 23 March 2018 and if the court jailed him he would not have been able to attend the investiture debate, scuppering his chances of becoming president. At the investiture vote held on 22 March 2018 Turull secured 64 votes with 65 votes against, four abstentions and two absentees. A second vote on Turull's candidature was to be held on 24 March 2018 but on 23 March 2018 Llarena remanded in custody Turull and four other Catalan leaders. On 3 April 2018 and 24 April 2018 the Catalan Parliament's bureau approved the two absentee MPs - Puigdemont and Antoni Comín - voting by proxy. Turull's investiture vote had set in motion a two month deadline for a new president to be sworn in or else parliament would be dissolved and elections called. On 10 May 2018 Puigdemont nominated Quim Torra, the so-called "plan D", to be president. At the investiture vote held on 12 May 2018 Torra secured 66 votes with 65 votes against and four abstentions, failing to achieve the 68 votes necessary for an absolute majority. As a result a second vote was held on 14 May 2018 at which he only needed a simple majority to become president. The result of the second vote was exactly the same as the first vote - 66 in favour, 65 against and four abstentions - and as a result Torra was elected the 131stPresident of Catalonia. King Felipe issued a royal decree on 15 May 2018 approving Torra's appointment and on 17 May 2018 he was sworn in. On 19 May 2018 Torra announced his new government of 13 ministers, two of whom were in jail and two were in exile. The Spanish government condemned the inclusion of jailed/exiled politicians as provocative and refused to approve Torra's appointments or to revoke direct rule. Faced with this opposition Torra announced a new government on 29 May 2018 without the jailed/exiled politicians. In one of his last acts, ousted Spanish Prime Minister Mariano Rajoy ordered that direct rule be lifted as soon as the new ministers were sworn in. On 2 June 2018 the new ministers were sworn in at the Palau de la Generalitat de Catalunya, ending seven months of direct rule.