Officials in Somalia say they are questioning 20 foreign nationals who had spent years with the al-Shabab militant group.
The men from Pakistan and Iran said they had been working as fishermen before being captured by Somali pirates.
The Pakistani and Bangladeshi men have told local officials that they were fishermen who after being captured by pirates were then held for eight years by al-Shabab in Harardhere - a town controlled by the Somali jihadist group.
It is not yet clear what led to their release on Saturday.
The 20 men made their way to the nearby coastal town of Hobyo - which for several years had been at the centre of Somalia's lucrative piracy trade.
The district commissioner there, Abullahi Ahmed Ali, told the BBC they were being questioned and discussions were taking place with the Mogadishu government.