Somalia's Prime Minister Mohamed Hussein Roble and regional state presidents signed an agreement to allow elections to take place after months of delays, the state-run broadcaster said on Twitter.
Clan elders were meant to have selected legislators in December, who in turn were due to elect a new president on February 8. Both procedures failed to take place as disputes raged over a number of issues including the composition of an election commission to supervise the voting.
"The prime minister and state leaders signed the election agreement," Somalia News Agency said on Twitter. It gave no details of the agreement itself, nor of any new schedule for the elections.
Mr Roble praised leaders of the federal member states and the Governor of Banadir for their role in the agreement.
"They have truly shown a great degree of flexibility, compromise, patience and leadership," he said.
Somalia initially aimed to hold its first direct election since civil war erupted in 1991, but delays in preparations and continuous attacks by Al Shabab had forced it to resort to an indirect vote.
President Mohamed Abdullahi Mohamed is seeking a second term. The opposition accuses him of packing regional and national electoral boards with his allies.
In April, the lower house of parliament voted to extend the president's four-year term by two years. The Senate rejected the extension, and troops opposed to the move seized positions in the capital. They have since returned to barracks.
The political crisis is causing concern that clans could turn on each other allowing Al Shabab, a militant group linked to Al Qaeda, to exploit the security vacuum.