In Somalia's main pirate lair of Haradheere, the sea gangs have set up a cooperative to fund their hijackings offshore, a sort of stock exchange meets criminal syndicate.

Heavily armed pirates from the lawless Horn of Africa nation have terrorized shipping lanes in the Indian Ocean and strategic Gulf of Aden, which links Europe to Asia through the Red Sea.

The gangs have made tens of millions of dollars from ransoms and a deployment by foreign navies in the area has only appeared to drive the attackers to hunt further from shore.

It is a lucrative business that has drawn financiers from the Somali diaspora and other nations -- and now the gangs in Haradheere have set up an exchange to manage their investments.

One wealthy former pirate named Mohammed took Reuters around the small facility and said it had proved to be an important way for the pirates to win support from the local community for their operations, despite the dangers involved.

Four months ago, during the monsoon rains, we decided to set up this stock exchange. We started with 15 'maritime companies' and now we are hosting 72. Ten of them have so far been successful at hijacking, Mohammed said.

The shares are open to all and everybody can take part, whether personally at sea or on land by providing cash, weapons or useful materials ... we've made piracy a community activity.

Haradheere, 400 km (250 miles) northeast of Mogadishu, used to be a small fishing village. Now it is a bustling town where luxury 4x4 cars owned by the pirates and those who bankroll them create honking traffic jams along its pot-holed, dusty streets.

Somalia's Western-backed government of President Sheikh Sharif Ahmed is pinned down battling hard-line Islamist rebels, and controls little more than a few streets of the capital.

The administration has no influence in Haradheere -- where a senior local official said piracy paid for almost everything.

Piracy-related business has become the main profitable economic activity in our area and as locals we depend on their output, said Mohamed Adam, the town's deputy security officer.

The district gets a percentage of every ransom from ships that have been released, and that goes on public infrastructure, including our hospital and our public schools.

RISK VS REWARDS

In a drought-ravaged country that provides almost no employment opportunities for fit young men, many are been drawn to the allure of the riches they see being earned at sea.

Abdirahman Ali was a secondary school student in Mogadishu until three months ago when his family fled the fighting there.

Given the choice of moving with his parents to Lego, their ancestral home in Middle Shabelle where strict Islamist rebels have banned most entertainment including watching sport, or joining the pirates, he opted to head for Haradheere.

Now he guards a Thai fishing boat held just offshore.

First I decided to leave the country and migrate, but then I remembered my late colleagues who died at sea while trying to migrate to Italy, he told Reuters. So I chose this option, instead of dying in the desert or from mortars in Mogadishu.

Haradheere's stock exchange is open 24 hours a day and serves as a bustling focal point for the town. As well as investors, sobbing wives and mothers often turn up there seeking news of male relatives missing in action.

Every week, Mohammed said, gang members and equipment were lost to the sea. But he said the pirates were not deterred.

Ransoms have even increased in recent months from between $2-3 million to $4 million because of the increased number of shareholders and the risks, he said.

Let the anti-piracy navies continue their search for us. We have no worries because our motto for the job is 'do or die'.

Piracy investor Sahra Ibrahim, a 22-year-old divorcee, was lined up with others waiting for her cut of a ransom pay-out after one of the gangs freed a Spanish tuna fishing vessel.

I am waiting for my share after I contributed a rocket-propelled grenade for the operation, she said, adding that she got the weapon from her ex-husband in alimony.

I am really happy and lucky. I have made $75,000 in only 38 days since I joined the 'company'.

(Writing by Daniel Wallis; Editing by Jon Boyle)