Somalia's government announced on Thursday that delayed elections would be held within 60 days, following months of deadlock over the vote that erupted into violence in the troubled country.
President Mohamed Abdullahi Mohamed and state leaders had been unable to agree on the terms of a vote before his term lapsed in February, triggering an unprecedented constitutional crisis.
The political impasse exploded into violence in April when negotiations collapsed and the lower house of parliament extended the president's mandate by two years, sparking gun battles on the streets of Mogadishu.
Under pressure the president, better known as Farmajo, reversed the mandate extension and ordered his prime minister to reconvene with the leaders of Somalia's five states to chart a fresh roadmap toward elections.
"About the schedule of elections, the national consultative forum agreed that elections will be held within 60 days," said deputy information minister Abdirahman Yusuf at the conclusion of five days of negotiations in the capital.
The exact dates for parliamentary and presidential elections would be determined by the electoral board, he added.
"It is a historic day," said Prime Minister Mohamed Hussein Roble, whose office will take charge of overseeing the electoral process.
Farmajo thanked the various parties for compromising, declaring the outcome "a victory for Somali people everywhere".
Somalia's foreign partners -- including key backers who threatened sanctions if polls were not quickly held -- also welcomed the breakthrough.
"We now urge all stakeholders to move forward swiftly to organize inclusive and transparent elections without delay," read a statement issued by the UN signed by the US, Britain, EU and other western and regional powers.
Somalia's elections follow a complex indirect model whereby special delegates chosen by the country's myriad clan elders pick lawmakers, who in turn choose the president.
The United Nations has described a one-person, one-vote election as essential for Somalia's democratisation but the milestone has eluded the fragile country for half a century.
Successive presidents have promised a direct vote but political infighting, logistical problems and a violent insurgency by the Al-Shabaab militant group has prevented such an exercise.
- Distrust -
Farmajo and the states agreed in September on a path to elections, again abandoning universal franchise for the indirect model, but increasing the number of delegates to make the process more inclusive.
But distrust over key appointments to crucial election committees, fears of rigging, and concerns about securing the vote itself, scuttled the plan.
Months of UN-backed negotiations failed to get the timetable back on track, with the crisis culminating in parliament approving the mandate extensions despite opposition from the Senate and the states.
The crisis stoked fears of outright civil war as soldiers deserted their posts in the countryside to fight for their political allegiances in the capital.
At least three people died in the clashes, with government losing control of key parts of Mogadishu as roads were sandbagged and fighters with machine guns watched key junctions.
The fighting drove tens of thousands of people from their homes, as the international community called for a ceasefire and urged the warring sides to again come to the table.
Opposition forces withdrew in early May after Roble assured the political opposition that their concerns would be heard.
Somalia has not had an effective central government since the collapse of Siad Barre's military regime in 1991, which led to decades of civil war and lawlessness fuelled by clan conflicts.
The Horn of Africa country still faces a violent insurgency from the Al-Qaeda-linked Al-Shabaab group, which controlled the capital until 2011 when it was pushed out by African Union troops.