Ukraine's foreign ministry says pirates have released a Ukrainian cargo ship that was seized last month off the coast of Somalia.

The ministry says the crew of the vessel is safe after being freed late Saturday.

The pirates hijacked the ship on October 18 and demanded a ransom of $700,000. It is not clear if the ransom was paid.

Piracy has been rampant in the waters off Somalia, which is torn by fighting among various militias. At least 23 hijackings have been reported since March.

Some information for this report provided by AP.