International navies and private security officials have dramatically curtailed piracy attacks at sea off the coast of Somalia in the last few years. But on land, the East African nation still suffers from extreme economic hardship, civil unrest and political turmoil after decades of conflict that have left unemployed youth desperate to earn a basic income.

An attack by Al Shabab gunmen on Tuesday at a government compound, which holds the higher education and petroleum ministries, left at least 17 people dead in Somalia's capital city of Mogadishu. Last month, the Islamist militants seized a Mogadishu hotel and killed at least 18 people during a deadly battle with Somali security forces, which lasted more than 12 hours. The al Qaeda-linked group has launched almost monthly attacks in Somalia and cross borders since last year in an effort to expand its territory and overthrow the Somali government. The violence has unfolded as Somalia has struggled under a fractured government and weak economy. Some 80 percent of Somalis living in urban areas are currently unemployed and there are few legal options for them to make money.

“There’s no question that extremely high levels of unemployment have meant that young men are looking to make a livelihood from a gun," said Ken Menkhaus, a professor of political science at Davidson College in North Carolina whose research focuses on the politics of the Horn of Africa. "Piracy was one of the many possibilities."

Clan warlords have battled for power in Somalia since the collapse of a military dictator's regime in the early 1990s. After years of interim authority, a federal government headed by the president and parliament was established in 2012. But Somalia's internationally-recognized government has failed to assert central authority over the nation. Much of Somalia is controlled by Al Shabab, which emerged in 2006 from the now-defunct Islamic Courts Union that controlled Mogadishu. Al Shabab launched its own insurgency on major Somali cities by 2009. The militants were pushed out of Mogadishu and other strategic cities by Somali and international forces around 2012. But Al Shabab has recently increased efforts to oust the United Nations-backed government, and the terror group still dominates many rural areas of Somalia where it has imposed a strict version of Shariah law.

High unemployment and a lack of national authority created a niche for piracy in Somalia. One armed pirate can earn between $6,000 and $10,000 for a $1 million ransom, according to a 2008 report commissioned by the United Nations. The ransom money saw piracy surge in 2011, when there were 736 hostages and 32 ships held. Somali pirates profitted by hijacking merchant vessels and sharing the profits with their clan and financial backers. 

The European Union, the United Nations and other international groups responded by deploying naval forces to regularly police the waters and to train Somali coast guards. Foreign shipping industries hired private security officials to protect their crew onboard. What was once a low-risk, high-reward job for Somali pirates became much more difficult to pull off. 

Today, there are 26 hostages and no ships being held, said Commander Jacqueline Sherriff, spokeswoman for the EU Naval Force. United Nations and Somali officials, however, warned last month the anti-piracy campaign has allowed for an increase in illegal fishing, which could revive Somali-based piracy by providing a pretext for the pirates to hijack vessels, Reuters reported. Experts said increased piracy is unlikely in the future as long as security efforts remain resilient at sea. But that doesn't eliminate the allure of using illegal avenues to make a substantial amount of money.

“We have taken away the opportunity [for piracy] but we’ve not been able to take away the intent.” Sherriff said. “The threat very much still remains. We need to all remain vigilant.”

The EU Naval Force works closely with other EU missions in the East African country dedicated to help ease poverty, starvation and unemployment, and the EU has poured millions of dollars into Somalia. But the country’s lack of a sustainable economy and an effective national governance is a vast undertaking which experts said will take decades to repair.

“It’s going to be on the ground where this issue is solved,” said James Kraska, a professor at the U.S. Naval War College in Rhode Island who specializes in maritime security. “The requirements or the needs in Somalia are just about limitless there.”

Somalis have suffered from unemployment, poverty and hunger for over two decades. Famine killed nearly 260,000 people in Somalia between 2010 and 2012, according to the United Nations. Young men who would have sought piracy to make ends meet could now turn to militias and other armed groups.

“If someone is a young Somali man today, there’s a very strong – almost gravitational – pull to either be in a militia or to be a pirate, because there’s not much else by way of employment,” said Kraska.