Abdullahi Yusuf, the president, and Sharif Hassan Sheikh Adan, the speaker, have been arguing over whether the government should be established in the capital city Mogadishu as stipulated by a transitional national charter.
The final declaration signed by the two men in Yemen on Thursday made no mention of a venue for the government.
A Yemeni official close to the talks said the leaders had intentionally omitted the location of the government to avoid angering faction chiefs in Somalia.
He said: "In principle, they agreed that the government will first move to Baidoa and then Mogadishu."
Baidoa is considered a neutral city while Mogadishu is seen by Yusuf's faction as a stronghold of Hassan's group, which comprises more than 100 politicians and powerful warlords in the cabinet.
Claiming that the capital is too dangerous, Yusuf and his supporters have made their temporary base in Jowhar, a town 90km to the north, after leaving exile in Kenya.
The final declaration said both leaders had agreed to "co-ordination between state organisations that was based on total respect of the national charter".
Baidoa has been suggested as
a neutral venue for government
The declaration signed in the Yemeni city Aden said: "Both leaders have reached an agreement to start a new page and end their differences which have brought serious damage to the duties of the institutions and the spirit of the Somali people."
Ali Abdullah Saleh, the president of Yemen, has been mediating talks between the two leaders as their respective factions have refused to meet in Somalia.
The declaration said Yusuf and Hassan had agreed to ask parliament to meet within 30 days in a location inside Somalia that would be announced later.
It said: "Both also called upon the members of parliament and government to put aside their fruitless squabbles and differences, urging them to unite, placing the supreme interest of the nation above other interests."
Sources close to Yusuf had proposed either Baidoa or Kismayo, neutral cities in the south of Somalia as venues.