John Steed, a former British army colonel who has spent years helping negotiate their release, said the men had "sneaked out a window" to escape their captors.
"It is great news that they are at least free... given what they have been through, they are all in good health," Steed told AFP after arriving safely in Kenya with the men on a special flight from Somalia.
After escaping through a window from their pirate prison, the men were rescued by security forces from the northern Somali Galmadug region, Steed added.
Their boat, the Malaysian-flagged container ship MV Albedo was captured in November 2010 but sank in rough seas last July.
During their captivity, one Indian colleague was shot by the pirates in an argument, and four others from Sri Lanka drowned.
Seven other Pakistani crew members were released in 2012 after a businessman paid their ransom, but those remaining could not afford the hefty demands of the pirates.
"The crew members and their families have suffered unimaginable distress," United Nations special envoy to Somalia Nicholas Kay said in a statement.
"The crew underwent the trauma of piracy, their ship sinking, and then being held ashore in very difficult conditions." v - 38 hostages remain -
The United Nations said they had been handed over to its care, and "will be repatriated to their home countries over the coming days."
The sailors, like 38 others from different boats who remain captive, were abandoned by their ship's owner whose willingness to pay to free them sank along with their boat.
"While we have seen a significant reduction in piracy off the coast of Somalia in recent years, I remain deeply concerned that 38 other crew members are still being held hostage," Kay added.
Pirate attacks off Somalia have been slashed 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.
"I call on those who continue to detain these crew members to release them without further delay so they can rejoin their families and loved ones," Kay said.
On Thursday, three Kenyan aid workers held hostage by pirates in northern Somalia for close to two years were also freed unharmed.The two men and a woman had been travelling in a convoy guarded by armed police, were seized by gunmen in ambush in the Galkayo area of the northern autonomous Puntland region of Somalia in July 2012.
All three Kenyans were flown back to Nairobi Saturday along with the sailors, and were welcomed at the airport by emotional families who embraced the aid workers, several in tears, Steed said.
Foreign special forces have launched raids to rescue their nationals, including one in 2012 by US elite commandos who swooped in by helicopter to free two aid workers held for three months.
Those left behind come largely from nations without the capabilities or desire to send in troops to rescue impoverished fishermen.