(Reuters) -Turkey has begun mediating talks between Somalia and Ethiopia over a port deal Addis Ababa signed with the breakaway region of Somaliland earlier this year, Ankara and four officials familiar with the matter said.

The negotiations are the latest attempt to mend diplomatic ties between the East African neighbours, whose relationship soured in January when Ethiopia agreed to lease 20 km (12 miles) of coastline from Somaliland, in exchange for recognition of its independence.

Mogadishu called the agreement illegal and retaliated by expelling the Ethiopian ambassador and threatening to kick out thousands of Ethiopian troops stationed in the country helping battle Islamist insurgents.

Turkey's foreign ministry said Foreign Minister Hakan Fidan had hosted both his Ethiopian and Somali counterparts in Ankara, adding the three had signed a joint statement following "candid, cordial and forward-looking" talks on their differences.

The Somali and Ethiopian ministers discussed ways to address their differences "within a mutually acceptable framework", and agreed to hold another round of talks in Ankara on Sept. 2, the statement said.

"The Ministers of Somalia and Ethiopia reiterated their commitment to the peaceful resolution of differences," it added.

Spokespeople for the Somali government and Ethiopia's foreign ministry, government and intelligence service did not immediately respond to requests for comment.

A spokesperson for Somaliland, which has struggled to gain international recognition despite governing itself and enjoying comparative peace and stability since declaring independence in 1991, said it was not involved in the talks.

The goal of the negotiation was unclear, and expectations of a resolution were low, two of the officials said.

"Despite rumours that Somalia has softened its stance on refusing to engage in dialogue until Ethiopia withdraws the (agreement), it seems unlikely," one of the officials said.

"I don't see a way forward, and I don't expect much will come from these talks."

Turkey has become a close ally of the Somali government since President Recep Tayyip Erdogan first visited Mogadishu in 2011, training its security forces and supplying development assistance.

The two nations signed a defence pact in February under which Ankara will provide maritime security support to Somalia to help the African country defend its territorial waters.

Turkey has built schools, hospitals and infrastructure and provided scholarships for Somalis to study in Turkey, and in return secured a foothold in Africa and on a key global shipping route.

A Turkish diplomatic source said Ankara's mediation efforts began after Ethiopian Prime Minister Abiy Ahmed visited Erdogan in Ankara in May and conveyed a letter asking Turkey to mediate between Somalia and Ethiopia.

(Reporting by Giulia Paravicini and Tuvan Gumrukcu; Additional reporting by Dawit Endeshaw; Editing by Hereward Holland, Alex Richardson and Jonathan Oatis)

By Giulia Paravicini and Tuvan Gumrukcu