(CNN) -- Despite days of rallies supporting him in the capital city of Mogadishu, Somali Prime Minister Mohamed Abdullahi Farmajo resigned Sunday.
''I have decided to resign from the post of the prime minister, and I am doing this as a sacrifice for the interest of the Somali public," Mohamed Abdullahi Farmajo told reporters at the presidential palace.
His resignation comes after Somali President Sheikh Sharif Sheikh Ahmed and Sharif Hassan Shiekh Adan, speaker of the Somali parliament, signed an accord in Kampala, Uganda, earlier this month mending a long-standing rift between them.
Under terms of the U.N.-backed accord, the mandates of the two officials and their deputies were extended until August 20, 2012, when new elections will be organized. Farmajo's resignation was part of that agreement.
"Under the agreement, known as the Kampala Accord for the Ugandan capital in which it was signed, the terms of the presidency and the parliament have been extended by one year, while a new prime minister should be appointed within the next 30 days," according to the United Nations. The agreement was hailed as "a breakthrough in ended the political impasse over the current transition period."
Before the agreement, Somali officials had been divided over how to handle the country's governance after August, when a transitional period was set to expire, the United Nations said.
Somalia has not had a fully functioning national government since 1991, according to the United Nations.
Demonstrators in Mogadishu supported Farmajo. Under his leadership, government soldiers received their salaries and began combating the militant al-Shabaab group.
The president praised Farmajo "for his brilliant work during his leadership."
Abdiweli Mohamed Ali was appointed as an interim leader until a new prime minister can be appointed.