Seven pirates have been given life sentences for seizing a United Arab Emirates ship last week by a court in Somalia's northern Puntland region.
Another four were given similar sentences for helping the pirates.
They were convicted of "taking people hostage with the aim of obtaining a ransom" a local official said.
Somalia's water are among the most dangerous in the world. Last year, more than 25 ships were seized off the coast of Somalia.
Naval ships from countries including France and the US now patrol the Red Sea to deter the pirates.
The pirates are being held in the Puntland capital, Bosasso.
The authorities in the semi-autonomous region of Puntland stormed the Al-Khaleej last Tuesday.
One pirate was shot dead in the battle, reports the AFP news agency.
In the latest incident, a Spanish fishing boat and its 26 crew members were released over the weekend after several days in captivity.
A local official told the BBC a $1.2m ransom had been paid.
Earlier this month, six suspected pirates were detained by the French military after a French yacht was seized.
Somalia has not had an effective central government for more than 17 years and is plagued by insecurity.