A showdown between Somalia's pirates and the country's most powerful Islamic army was avoided this week, but the standoff shed light on the growing and complicated relationship between the two groups.
Somalia's fiercest Islamic group al-Shabaab had advanced on the pirate stronghold of Harardhere, but were repelled by a pro-government militia.
The rampant piracy of the last few years has yet to be directly tied to the network of Islamic fighters that has been classified by Washington and other western countries as terrorists.
For a long time the two remained separate, divided as much by geography as by ideology. Pirates were concentrated in the Gulf of Aden near Puntland in northern Somalia, hundreds of miles from the nearest Shabaab stronghold.
But as the international community cracks down on the Gulf's corridor, and Shabaab's influence grows further north, the pirates' areas of operations came closer to Shabaab-controlled areas.
The two have had an uneasy co-existence. While there's little evidence the Islamists are directly involved with piracy, Puntland's Director General Abdiwahid Mohamed Hersi told ABC News that some of the millions of dollars in pirate ransoms end up in Shabaab's hands.
"The pirates pay Shabaab 'taxes' of up to $100,000 on ransom monies," Abdiwahid Mohamed Hersi told ABC News during a recent trip to Somalia.
The relationship extends beyond just a cut of the ransom. Sometimes there is protection and training involved as well, says Andrew Mwangura of the East Africa Seafarer's Assistance Program, which tracks piracy in the region. "Some of the pirates go to Shabaab to receive weapons training," Mwangura claims.
A full-fledged merger remains unlikely because, Mwangura says, it's not good for either group. Shabaab has publicly-stated its desire to rule all of Somalia using strict Sharia-law, and has been known to cut off the limbs of men and women accused of stealing items as small as cell phones. The group has also made public statements against piracy, calling it un-Islamic.
Shabaab has its own, often brutal, court and justice system, and group elders in cities charge taxes on businesses. As long as the business pays the tax and follows Shabaab's laws, there's no issue. Mwangura says the business of piracy is no exception.
"The rule is: Don't attack any ship that has ties to Al Shabaab or business in the southern part of Somalia, and we will leave you alone," he says.
So why were there reports of the pirates frantically moving to another city to take cover from an approaching Shabaab army? Because the pirates broke the rule.
Published reports said the Shabaab fighters were after a ship hijacked by the pirates that was filled with arms, but Mwangura could not confirm that. He did say the Shabaab was angry at the pirates for hijacking Indian dhows carrying charcoal to the southern port of Kismayo.
"These Indian dhows carry charcoal that's needed for Shabaab to sell and get revenue," says Mwangura. "When a shipment comes into Kismayo they have to pay taxes to the port authorities, which are run by Shabaab. So when these ships are hijacked that's also a loss of revenue for Shabaab."