In Spain, Prime Minister Jose Luis Rodriguez Zapatero said the tuna boat Alakrana "is sailing toward safer waters. All of its crew members are safe and sound."
A Somali villager named Ali Ahmed Salad said 12 armed pirates left the ship shortly after noon Tuesday and joined colleagues near the pirate town of Haradhere.
Ali Gab, a self-proclaimed pirate, told The Associated Press that a boat delivered $3.3 million in ransom. Gab said pirates began leaving the ship shortly afterward, and that a Spanish warship nearby watched the proceedings.
Cmdr. John Harbour, a spokesman for the EU's anti-piracy force, confirmed that a Spanish warship had been in the region.
Zapatero was evasive when asked if the government had taken part in payment of a ransom. "The government did what it had to do," he told a news conference after talks with the president of Hungary, Laszlo Solyom.
The reported ransom payment demonstrates why pirate attacks have been on the rise. The millions of dollars a successful hijacking can bring is a windfall in impoverished and war-ravaged Somalia.
The trawler was seized Oct. 2 with 16 Spaniards, eight Indonesians and 12 crew from five African countries aboard. The pirates holding the Alakrana had been pressing for the release of two colleagues who were captured by Spanish naval forces a day after the hijacking and eventually brought to Madrid to face charges.
The Spanish government has been working feverishly to find some sort of legal formula that would allow it to try them and send them back to Somalia quickly in hopes of appeasing the pirates who remained in control of the trawler.
In the end, the hostages were released with the two Somali suspects still in custody in Madrid. They were formally charged with kidnapping and related charges Monday.
In the latest attempted hijackings, pirates attacked two vessels Monday off East Africa, successfully capturing one of the ships and its crew of 28 North Koreans, officials said Tuesday.
The pirates attacked a chemical tanker named the MV Theresa with the 28 crew members on board, the European Union's anti-piracy force said. The vessel, which was operated out of Singapore, had been heading to the Kenyan port town of Mombasa. The EU force did not say what kind of chemicals were on board.
In a second incident Monday, pirates attacked a Ukrainian cargo ship with AK-47 rifles and rocket-propelled grenades after two small skiffs detached from a mother ship. Harbour, the EU Naval Force spokesman, said that private security guards on board fired on the pirates, wounding two. The pirates then broke off the attack, the force said, Harbour said the Ukrainian ship was not hijacked.
A Somali man who claims to be a spokesman for the pirates, Gedi Ali, said Tuesday that pirates had captured the Ukrainian ship. Ali also said two pirates were wounded in the attack.
Pirates hold around a dozen ships and more than 200 crew, and attacks have increased in recent weeks as the monsoon season subsided. An international flotilla of warships now patrols the Indian Ocean and Gulf of Aden, but pirates continue to carry out attacks because of the millions of dollars that can be made from a successful hijacking.