Somalia\'s transitional President Sharif Sheikh Ahmed and the parliament speaker on Thursday signed a deal extending their terms for a year and got international approval for the move, a UN statement said. Ugandan President Yoweri Museveni and the UN\'s Somalia representative Augustine Mahiga witnessed the signing of the accords by Sharif and speaker Sharif Hassan Sheikh Aden, a statement said. They agreed \"to defer elections of the President and the Speaker and his deputies for twelve months from August, 2011 in order to adequately prepare and complete priority transitional tasks,\" the accord said. Sharif had previously called for the extension, saying Somalia was too unstable for elections as it battles Al-Qaeda-inspired Islamist militants. Parliament and the government had earlier announced unilateral prolongations of their respective mandates but came in for international criticism. The accord \"represents a very fundamental agreement between the two main players on the Somali political scene,\" Mahiga told AFP in Kampala. \"This is a major breakthrough as we have basically agreed on not only deferring the elections but on putting in place a mechanism that will ensure the implementation of important transitional tasks that have to be complete in next 12 months,\" he said. The mandate for the UN-backed government was supposed to expire on August 20 and the United Nations had been pressing for the parties to decide when elections could be held. The accord stipulates \"Elections for President and Speaker of Parliament will have to take place prior to August 20, 2012.\" Museveni said last week a one-year mandate extension would avoid jeopardising military gains by African Union troops against the militants. Uganda has contributed several thousand troops to the African Union force that is backing the transitional institutions. Over the past five months pro-government forces have clawed back several key positions in Mogadishu. Uganda has on several occasions expressed concern that these military gains could be undermined by continued bickering within the transitional institutions. Thursday\'s agreement also provides for the prime minister to resign within 30 days and for the president to appoint a successor. Somalia\'s transitional government, which was set up in 2004 in Kenya and owes its survival to the international community, has been weakened by infighting between its leaders which has worsened as the end of the mandates approached. A Somali lawmaker involved in the negotiations told AFP that the speaker had agreed to defer the elections in return for the resignation of the prime minister, whom parliament accused of siding with the president. \"We said that if the president insists the elections be deferred then let\'s come to other terms (and have) a new prime minister and a government that can work with parliament,\" Somali legislator Abdulrahman Warsame said. Prime Minister Abdullahi Mohamed is not a signatory to Thursday\'s agreement and has so far made no official comment, but a few dozen of his supporters demonstrated in Mogadishu against the agreement. Warsame said Somali politicians hoped to establish a timetable for setting out when key transitional tasks would be completed. \"It is very important now to have a clear agenda for the next year,\" Warsame said.