A breakaway group of around 50 Somali militants who declared loyalty to the Islamic State militants abandoned a small port town on Thursday a day after occupying it, residents and an official said.
"The militants left town early this morning but they are not far away," said Abdiweli Adan, an elder in a town close to Qandala which the IS-linked group occupied on Wednesday.
He said the group's black flag still flew over government buildings in the small seaside town on the Gulf of Aden coast of Puntland, a semi-autonomous state in northern Somalia.
"Some fishermen saw them staying close by in mountainous enclaves," said Adan, who added the militants left as they had arrived, peacefully.
A security official in the regional capital Bossaso said the threat of an arriving force of Puntland soldiers had scared the militants off.
"Puntland sent hundreds of special forces to deal with the terrorists. Unfortunately, they have run away even before the forces reached the town," said Cabdirisak Mohamed, a security official in the capital Bossaso, about 70 kilometres (45 miles) west of Qandala.
Mohamed dismissed the takeover of Qandala as "a desperate attempt to draw attention."
The militants -- led by former Shabaab cleric Abdiqadir Mumin -- switched allegiance from Al Qaeda to IS a year ago but have done little since apart from issuing occasional promotional videos.
Nevertheless, in late August the US State Department named Mumin a "global terrorist" making him a potential target for US drone strikes which are regularly carried out against militants in Somalia.
Abdukadir Said, a trader from Qandala said aircraft flying over the town may have spooked the militants.
"There were aircraft hovering over Qandala during the last six hours" before they left, he said.
Once a pirate stronghold, Qandala is an ancient trading and fishing town whose main significance is its proximity to Yemen, across the Gulf of Aden, where Al Qaeda and IS groups both operate.
In the past the Shabaab has been resupplied with weapons and fighters sent from Yemen.