Somalia is prepared to go to war to stop Ethiopia recognising the breakaway territory of Somaliland and building a port there, a senior adviser to Somalia’s president has said.

A memorandum of understanding signed on 1 January allowing landlocked Ethiopia to develop a naval base on Somaliland’s coast has rattled the Horn of Africa, one of the world’s most volatile regions.

Somalia claims Somaliland as part of its territory and has declared the deal void. Last Sunday its president, Hassan Sheikh Mohamud, called on Somalis to “prepare for the defence of our homeland”, while rallies have been held in Mogadishu, Somalia’s capital, against the agreement.

“We are pursuing all diplomatic options and I think Ethiopia will come to its senses, but we are ready for a war if Abiy wants a war,” said the adviser, referring to the Ethiopian prime minister, Abiy Ahmed.

Ethiopia and Somalia fought a conflict in 1977-78 over a disputed region and tensions still run deep. Ethiopia invaded Somalia in 2006 to dislodge Islamists from Mogadishu, helping to spark the Al-Shabaab insurgency, and today it is one of the largest contributors of troops in the African Union peacekeeping force in Somalia.