"The hostages were freed without fighting. The security forces overwhelmingly besieged them and the pirates tried to flee, but three of them were captured," Abdirashid Mohamed Ahmed, deputy commander of the maritime force in Somalia's Galmudug state said.
Mr Ahmed said the newly freed crew members were "safe and healthy."
The forces had rescued the hijacked Indian cargo dhow, Al Kausar, on Monday, but the pirates managed to escape with the crew during an exchange of gunfire, authorities said. The vessel was seized earlier this month.
The Al Kausar, which was transporting cargo including wheat and sugar from Dubai via Yemen to Somalia's Bossaso port, was the third vessel hijacked in the space of less than a month off the coast of the East African nation.
The pirates had told Reuters that they would use the crew to bargain for the freedom of pirates jailed in India.
Somali pirate attacks peaked with 237 in 2012 but then declined steeply after ship owners improved security measures and international naval forces stepped up patrols.
But this month has seen a jump in such attacks, with two ships captured and a third rescued by Indian and Chinese forces after the crew radioed for help and locked themselves in a safe room.
Residents of the Somali coastline say piracy has resumed after local authorities issued permits for foreign fishing vessels to fish in Somali waters. They say the foreign vessels have cut nets belonging to locals and run down small boats.
(With inputs from Reuters and AFP)
Follow NDTV for latest election news and live coverage of assembly elections 2019 in Maharashtra and Haryana.
Subscribe to our YouTube channel, like us on Facebook or follow us on Twitter and Instagram for latest news and live news updates.