Sanhá took office despite the opposition of 15 of the 17 involved political parties, which said that the Prime Minister should be an independent. The 2004 parliamentary elections were won by the PAIGC, which won 45 of the 100 seats; the PRS emerged as the second strongest party in the National People's Assembly with 35 seats. The PRS agreed to support PAIGC in parliament in return for a number of important positions, although it did not get any ministers in the government. Ialá was released from house arrest shortly before the elections, and in March 2005 he was nominated by the PRS as its candidate in the presidential elections that year. However, he finished in third place in the first round, failing to qualify for the run-off, contested by Sanhá and Vieira. Ialá and the PRS protested against the outcome of the first round, claiming to have actually received the most votes, but Ialá later accepted the outcome, while still claiming to have received the most votes, and endorsed Vieira for the second round. After Vieira's assumption of office on 1 October 2005, a crisis within the PAIGC led to several splits that resulted in the PRS becoming the largest party in parliament. On 12 November 2006, Ialá was re-elected head of the PRS at the party's third congress, with about 70% of the vote; the previous leader, Nan Beia, received 20%. His victory was, however, disputed by his opponents within the party. In March 2007, the PRS formed a three-party alliance with the PAIGC and the United Social Democratic Party, as the three parties sought to form a new government. This led to a successful no-confidence vote against Prime Minister Aristides Gomes and his resignation later in the month; on 9 April, the three parties nominated Martinho Ndafa Kabi of the PAIGC for Prime Minister, with President Vieira appointing him to the post. On 17 April a new government was named, composed of ministers from the three parties. In May 2007, following an appeal for the annulment of the third ordinary congress by a faction of the PRS opposed to Ialá, the Regional Court of Bissau cancelled the congress' resolutions and removed Ialá from the party leadership. However, on 23 August 2007 the Supreme Court of Guinea-Bissau reversed this decision and restored Ialá to the party leadership. Members of the PRS were included in the government headed by Carlos Correia, which was appointed on 9 August 2008.