Pirates who seized a Comoros-flagged oil tanker released the ship Thursday without conditions, according to a Somali official.
Security official Ahmed Mohamed told The Associated Press the pirates have disembarked the ship, which is now heading to Bossaso port, the region's commercial hub.
Mohamed said the release occurred after negotiations by local elders and local officials with the pirates, who seized the tanker on Monday and held eight Sri Lankan crew members hostage.
Earlier Thursday, Naval forces clashed with the pirates after they opened fire.
The hijacking of the Comoros-flagged tanker Aris 13 was the first such seizure of a large commercial vessel off Somalia since 2012.
Abdirizak Mohamed Ahmed, the director of Puntand's anti-piracy agency, confirmed the release of the ship Thursday night to the AP and said naval forces had boarded it to escort it to port.
The European Union anti-piracy operation in the region had said the pirates had been holding the crew captive and demanding a ransom.
Ahmed said the Puntland naval forces had been dispatched to the area not to free the ship by force but to cut off any supplies to the pirates.
"Attacking the ship will not help, but instead it will endanger the lives of the crew," he said.
Families of the crew members had tearfully pleaded for the men to be released unharmed. Somali pirates usually hijack ships and crew for ransom. They don't normally kill hostages unless they come under attack.
The ship had been carrying fuel from Djibouti to Somalia's capital, Mogadishu, on Monday when it was approached by men in two skiffs and the tanker issued a call for help.
The pirates told authorities that the only reason they seized the ship was in protest of the illegal fishing in the area that has threatened livelihoods, not for ransom, Mohamed said.
The Associated Press contributed to this report.