Shimo la Tewa Mombasa's maximum security prison, is surprisingly close to the port city's luxury beach hotels. Located just across the road from the holidaymakers, it may as well exist in another world. Beyond its imposing gates set with thick iron bars are some of the most dangerous men in the Horn of Africa, crowded into a prison already at three times its capacity.
Among the inmates are more than two dozen Somalis – alleged to be members of the pirate gangs that have been terrorising shipping. Dozens more are set to join them as Kenya is used as a dumping ground for pirates being picked up every week by international navies. The Somalis already inside the stultifyingly hot and humid Shimo la Tewa are set apart from the other prisoners. Speaking in confidence, a duty officer said: "We are scared having them here. We don't know if they are al-Qa'ida or who they are."
Unable to speak Swahili or English, and in some cases unable even to understand each others' dialects, these young men are guinea pigs in an experiment in international law. The suspected pirates will face the Mombasa courts under the terms of a secret agreement signed between the UK and Kenya last December and later copied by the US and the EU. These memorandums of understanding will see what Human Rights Watch calls "Kenya's deeply flawed judicial system" take on cases described by maritime experts as a jurisdictional nightmare. The success or failure of these prosecutions will decide the fate of the attempted military solution to the piracy crisis.
Francis Kadima is one of the men tasked with stopping the experiment. From his dank basement office opposite Fort Jesus in Mombasa's old town the defence attorney has taken on the case of seven of the alleged pirates. He is convinced there is no legal basis for what is going on. "We're going to challenge the Kenyan court's authority," he says. "You cannot sign secret agreements. They have to show us these treaties."
British officials in Nairobi reject the term "secret" and say it is standard for government agreements to remain confidential. The UK insists that its human rights obligations to the prisoners have been met and that they will not face the death penalty.
Mr Kadima is happy to admit that he is the "underdog" and that the judiciary is under intense pressure to convict. The chaotic state of the Kenyan system is painfully apparent. In recent weeks, the justice minister has resigned over political interference in the appointment of judges and a UN envoy called for the sacking of the Attorney General.
Mr Kadima's clients, who in common with many suspected pirates have pleaded not guilty and claim to be innocent fishermen, were arrested by the US Navy on 11 February and handed over on 6 March to Kenya. They were found with weapons and equipment consistent with piracy, according to US officials. The lawyer quizzed his clients over the guns and said they told him that there is "no one in Somalia who isn't armed". The defence attorney says the case will fall down because while Kenya has ratified the UN Convention on the Law of the Seas which makes piracy in international waters a crime, it has not redrafted its domestic laws to reflect this.
Andrew Mwangura, a piracy expert based in Mombasa, agrees that Kenya's maritime laws are a mess. Mr Mwangura, who has been running the East African Seafarer's Assistance Programme for 13 years, describes the dumping of suspected pirates on Kenya as "illegal" and says the country only agreed because corrupt officials expect to profit from international funds earmarked for the trials.
Jared Magolo, another Mombasa attorney representing Somalis, insists that "dumping them on Kenya is not the answer". A former magistrate, he hopes Mombasa judges will have the "courage" to throw out the cases. "Other nations think this is the safest place to dump them. But the legal system is not prepared for this and Kenya needs to start to say 'no'."
A week which saw the first pirate attack on a US vessel in history has pushed the disintegration of the failed state of Somalia up the global agenda. In 2006, the political crisis on land – where there has been no functioning government since 1991 – was met with a military solution when the emergence of a home-grown Islamic movement prompted a US-backed Ethiopian invasion. That approach failed and the Ethiopians withdrew at the beginning of this year having helped to spawn a far more radical Islamic militia, al-Shabaab, which now rules much of the country.
Analysts fear that the same failed military solution is now being tried at sea where tens of millions of pounds are being spent daily on a multinational naval alliance, including an EU-US task force, a Nato flotilla and warships from Japan, Russia and India. "In the long run there's no military solution to the piracy issue," says Roger Middleton from the UK think tank Chatham House. "There needs to be a solution on land."
The figures back this up. Last year there were a record 134 attacks and 49 hijackings. So far this year, despite the military investment, there have already been 69 attacks and 17 sea-jackings. Much of the huge naval presence was dispatched in a hurry last year and with little thought of what they would do with any captured pirates. The US had one suspected Somali pirate aboard their ship for seven months, unsure what to do with him. In September last year a Danish vessel intercepted 10 suspected pirates and, after realising they couldn't prosecute them, were forced to set them ashore in Somalia. The British and German navies have also admitted releasing pirates.
Governments have turned to Kenya as the courts there managed to convict a group of Somalis three years ago after they were handed over by the US Navy. However, that conviction is being appealed. Mr Magolo says that if the Somalis win, the "six or seven other cases under way by then will be declared illegal".
The US has brought officials from its own Coast Guard to try and make the best possible case but as their maritime expert Captain Charles Michel explains: "The challenges are pretty daunting because you may actually have, for example, say, [US] Coast Guard and Navy personnel involved with Somali pirates who may have attacked a Panamanian vessel with a Filipino crew being tried in a Kenyan court."
If the trials in Mombasa were to collapse, experts warn that it could leave a Guantanamo-style problem with suspected pirates that no other country would accept and Kenya would be loathe to keep. Mr Middleton says there has been a "grave reluctance" in Europe and the US to prosecute pirates in their courts. "If the Kenyan option breaks down you're going to be left with a very serious situation," he says.
There is considerable unease in Mombasa itself. A senior officer at the Criminal Investigation Department in the city said it made "no sense" to become a dumping ground for pirates. Speaking on condition of anonymity, he asked: "Why don't the countries who arrest them take them back to their own courts?"
The answer to that, according to Mr Mwangura, is that the collapse of a high-profile case in the UK or US would lead to the suspects being granted asylum. "The next day you would have hundreds of Somalis claiming to be pirates and asking to be arrested. Most of them are only doing this to get out of Somalia."
Despite the furore, which will only increase after the hostage drama over US Captain Richard Phillips, Mr Kadima is determined to treat his Somali clients like he would any others. He says that no one from the Kenyan side has yet approached him over the pirates and said he would not welcome any interference. While insisting that he still has faith in "due process" in his country, he admits that one client he represented in an unrelated case was murdered and that an assassin made an attempt on his life as well. As he says this he leans forward to show a scar on his head. "Piracy is not a legal problem ... [and these cases] are not a deterrent. It's the bad conditions in Somalia that are giving rise to this in the first place."