The Somali government and the Islamist opposition agreed to implement a dormant ceasefire deal, paving the way for pro-government Ethiopian troops to quit the country.
The accord calls for the ceasefire, which was first signed in June, to finally come into force November five, said Susannah Price, spokeswoman for the UN envoy to Somalia.
The deal also calls for Ethiopian troops to pull out of areas in Mogadishu and the central town of Beledweyne by November 21, leaving them under the control of African Union troops in Somalia (AMISOM), said Price.
The agreement said "the second phase of Ethiopian troop withdrawal should be completed within 120 days," though Price was unable to say when exactly the 120-day countdown would begin.
The deal was signed by the government and the Alliance for the Re-liberation of Somalia (ARS) at UN-sponsored talks in Djibouti.
The agreement resurrected a June nine ceasefire deal between the government and the Alliance for the Re-liberation of Somalia (ARS). The ARS is an opposition umbrella group dominated by Islamists and based in the Eritrean capital of Asmara.
The deal's implementation was delayed after fighting flared up across the country.
Radical Islamists have refused to accept the accord until Ethiopian forces withdraw from the country, with one leading Islamist, Hassan Dahir Aweys, rejecting the June agreement.
Aweys, who the United States has accused of links to Al-Qaeda, did not immediately react to Sunday's deal.