Ethiopia and Somalia have agreed to end their bitter dispute over Addis Ababa's plans to build a port in the breakaway republic of Somaliland following talks in Turkey.
Turkish President Recep Tayyip Erdogan welcomed the "historic agreement", which he said would eventually ensure landlocked Ethiopia's access to the sea.
At the press conference he held hands with Ethiopian Prime Minister Abiy Ahmed and Somali President Hassan Sheikh Mohamud, who both agreed to respect one another's "sovereignty".
The two neighbours have been at loggerheads since January when Ethiopia signed a maritime deal with Somaliland - which Somalia considers as part of its territory.
It prompted fears of a wider regional conflict as Egypt has been backing Somalia - largely due to its anger with Ethiopia for building a dam on the River Nile.
Turkey has in recent years become an important geopolitical player in the Horn of Africa as it has close economic ties with Addis Ababa and security deals with Mogadishu.
Erdogan said the agreement - announced on Wednesday night in the Turkish capital, Ankara - was "the first step towards a new beginning".
"I congratulate both my brothers for reaching to this historic reconciliation with devotion and thank them for their constructive attitude," he said.
President Mohamud said his country was "ready to work with the Ethiopian leadership and the Ethiopian people".
While Prime Minister Abiy insisted Ethiopia's efforts to secure and reliable access to the sea did not threaten Somalia and the two had "addressed the misunderstandings that have occurred over the past year".
The feud began on New Year's Day, when Abiy signed a controversial deal with Somaliland to lease a 20km (12-mile) section of its coastline for 50 years to set up a naval base.
In exchange, Ethiopia - the world's most-populous landlocked nation - was to reportedly recognise Somaliland as an independent country, although Addis Ababa never explicitly confirmed this.
Somaliland, which broke away from Somalia more than 30 years ago, has long been pushing for recognition - but Mogadishu described the move as an act of "aggression".
According to the Ankara joint declaration, the two Horn of Africa neighbours are to reconvene in February to hold "technical talks".
In the interim they will strive to reach "mutually beneficial commercial arrangements" to ensure Ethiopia gains access to the sea "under Somalia's sovereignty".
It is not clear if Ethiopia has discarded the deal it signed with Somaliland - something demanded by Somalia at earlier mediation efforts.
Last month, Somaliland elected a new president - former opposition leader Abdirahman Mohamed Abdullahi - who promised to "review" the maritime deal.
During his inauguration speech on Thursday morning he made no mention of it.
Somaliland is located in a strategic part of the world, and is seen as a gateway to the Gulf of Aden and the Red Sea.
Additional reporting by Bidhaan Dahir in Hargeisa.