Shipping company Shipcraft said it had paid the hijackers "considerable millions, substantially more than previous kidnappings where Danish citizens have been involved".
It declined to reveal the amount "considering possible future kidnapping situations".
Danish broadcaster TV2 said the hostage-takers received USD 6.9 million (5.2 million euros), paid in two instalments dropped into the sea on Tuesday and Thursday last week.
The sailors will be reunited with their families as soon as possible and are receiving medical treatment and counselling, the Danish government said in a statement.
Also Read
"I have just talked to the families of the seamen. It was a very emotional moment, and it goes without saying that the happy news was received with great joy," chief executive Claus Bech said in a statement.
The crew spent most of their time in captivity on land after the pirates damaged the cargo ship before leaving it adrift.
"They were moved to different locations in Somalia. On a few occasions the hostages have been allowed to talk to their families," Shipcraft said.
"These are cynical and unscrupulous people who deserve to be caught and prosecuted," Foreign Minister Villy Soevndal said in a statement.
"Although the international effort against piracy means it's increasingly rare for Somali pirates to successfully take new hostages, there are still other sailors caught out there," he added.