Spain is planning to hand over at least 13 suspected Somali pirates to Kenyan authorities for prosecution.
The suspects are being turned over as part of an agreement between the European Union and Kenya to have captured pirates tried in Kenyan courts.
The Spanish navy seized the men off the coast of Somalia last Wednesday after their boat capsized during an alleged attempt to hijack a Panamanian-flagged vessel.
The fate of the men had been in doubt after a Spanish judge ruled Friday the pirates should be released.
The judge originally said it would violate the law to turn them over to Kenya since proceedings were already taking place in Spain.
But after an inquiry from the Defense Ministry, the judge later said his ruling did not prevent the pirates from being released in Kenya.
France is prosecuting 15 piracy suspects in its own courts, though it has transferred others to Kenya, including 11 who were handed over on Friday.
The European Union and several other foreign navies, have established patrols to protect merchant ships in the region. Despite the patrols, Somali pirates have continued to hijack commercial vessels for ransom.
Some information for this report was provided by AFP.