Seven Bangladeshi sailors, held hostage by Somali pirates for almost four years, have returned home, comparing their experience to "hell".

The sailors, who had been held in dire conditions and suffered beatings, flew into the Bangladeshi capital on Thursday after lengthy negotiations to free them.

"Every day in captivity was like hell. We were not given proper food. They used to torture us on almost every day for ransom," Abul Kashem, one of sailors, told reporters at Dhaka airport.

Although Bangladesh said the sailors were freed, other officials have contradicted the claim, saying they were among 11 sailors mostly from Asia who escaped last week and were taken to safety in Kenya.

The group "sneaked out a window" to escape their captors, before being rescued by local security forces, a British mediator who helped secure their freedom said last week. 

Their boat, the Malaysian-flagged-ship MV Albedo, was hijacked in November 2010 by Somali pirates in the Indian Ocean.

During their captivity, one Indian colleague was shot by the pirates in an argument, and four others from Sri Lanka drowned.

"The sailors are in good health, but they are still shocked and  traumatised," the AFP news agency quoted Khurshed Alam, a Bangladesh foreign ministry official, as saying.

The government did not pay any ransom for their freedom, which came after months of negotiations involving third parties, Alam said.

Alam credited the London-based Maritime Piracy Humanitarian Response Programme, an alliance of ship owners, unions, agents and insurers, with securing their release.

The number of pirate attacks off Somalia has dropped in recent years, with international fleets patrolling the Gulf of Aden and Indian Ocean, as well as armed guards being posted aboard many vessels.

At their peak in January 2011, Somali pirates held 736 hostages and 32 boats, some onshore and others on their vessels.