Updated

Two hostages were killed and 16 others freed when a Danish warship intercepted a cargo vessel that had been hijacked by pirates off Somalia's coast.

Navy spokesman Kenneth Nielsen said Tuesday that 17 pirates were detained in Monday's anti-piracy operation. He declined to give the nationalities of the hostages.

Danish ship HDMS Absalon had been following the hijacked vessel for several days, Nielsen said. The cargo ship had been used as a mothership from which pirates sailed out in smaller boats to attack other vessels.

He said HDMS Absalon intervened when the vessel tried to move away from the coast on Monday. "(It) stopped the mothership before it could become a threat against the shipping on the open sea."

The crew fired warning shots, but the boat failed to stop, said Nielsen. Danish forces then opened fire on the ship after getting permission from the NATO command that oversees the multinational anti-piracy force in the area.

Nielsen said the pirates then surrendered and the Danes took control of the ship.

The Danish navy said in statement that "two of the hostages were found seriously injured and even with speedy assistance from Absalon's doctor, their lives could not be saved."

It wasn't clear how the hostages were injured. Danish military prosecutors were investigating the incident, Nielsen said, adding that none of the pirates were wounded.

The HDMS Absalon joined NATO's Ocean Shield anti-piracy force in November. On Jan. 7, its crew captured a suspected pirate mothership and rescued 14 hostages from Iran and Pakistan.

They also arrested 25 suspected pirates -- 17 of whom were released. Eight others were handed over to Seychelles authorities and to Kenya for prosecution.

Piracy has emerged as a major threat to merchant ships traversing the sea lanes of the Indian Ocean and Arabian Sea. Pirates based in Somalia have been hijacking ships and holding the vessels and their crew for ransom.