The two massacres were 90 miles and more than three months apart. Yet there was much in common between last week’s devastating killing on a Mediterranean resort beach in Tunisia, which killed 38 mostly British people, and the mass shooting last March in the country’s premier cultural institution, the Bardo National Museum in the capital Tunis, which killed 22 people — almost all Europeans.
Both targeted Western travelers, and both seemed aimed at wreaking havoc on the country’s crucial tourist industry, which provides some 20% of its income. And there was one other commonality too: Tunisian officials say the two gunmen in March, and the lone gunman in Sousse, all received terrorist training not in their tiny home country — but in Tunisia’s huge oil-rich next-door neighbor, Libya.
Western governments have anguished in recent days over the fact that armed militants appear to have taken root in Tunisia, which they regard as the sole success story from the Arab Spring revolutions of 2011; a secular political party won Tunisia’s democratic election last December. Since the Bardo museum attack, Tunisian officials have ramped up efforts to arrest suspected jihadists and shut dozens of unauthorized mosques, where they believe imams are radicalizing local youth. Last Saturday in Sousse, the site of the beach-resort attack, Tunisian President Mohsen Marzouk told reporters that the government was “trying to organize people in the war against terror,” which he said was “not between terrorists and the state, but between terrorists and the people.” The militant group Islamic State of Iraq and Greater Syria (ISIS) claimed responsibility for the museum attack, and this week, friends of the Sousse gunman, Seifeddine Rezgui, told the Financial Times that Rezgui had posted his allegiance to ISIS on his Facebook page.
Yet for all the hand-wringing over what to do about Tunisia’s militants, many believe that the key to averting more attacks lies not at home, but in Libya. There, regional analysts say, ISIS-affiliated organizations continue to operate unimpeded, offering training to terrorist operatives in how to conduct attacks elsewhere in the region. “They [ISIS affiliates] have identified Libya as their foothold in North Africa,” Matthew Sinkez, regional risk manager for Whispering Bell, a security consultant for companies operating in North Africa, said from his base in Dubai this week. In Libya, he said, “they have the ability to train people and further destabilize neighboring countries.”
The reasons are clear: nearly four years after Libya’s militia drove out Muammar Gaddafi and collapsed his 40-year dictatorship, the country has been beset by warring factions fighting for power. One group of militias called Libya Dawn seized the capital Tripoli last August, in a battle that destroyed the city’s airport and drove the internationally recognized leaders out of the capital, into internal exile in the eastern city of Tobruk. Since then, Libya’s military chief General Khalifa Haftar — ousted from Tripoli — has led a military campaign against Tripoli’s forces, and against ISIS-affiliated groups.
For nine months, U.N.-brokered peace talks in Morocco have failed to cobble together a deal between the two groups, and to persuade them to form a unity government to share power in Tripoli. But last week’s Sousse attack has made it clear that a peace deal is urgent. The U.N. envoy to the talks, Spanish diplomat Bernardino León, told reporters on Monday that he hoped to have a deal by Thursday, since the two sides needed to settle “just two, three issues.”
But Leon’s view now appears far too optimistic. On Wednesday, Libya Dawn said in a statement that it would not accept the peace conditions, and that they believed the U.N. was attempting to foist on them a “fascist dictatorship.”
The other side of Libya’s conflict is no less uncompromising, saying it would not agree to share power with the Tripoli leaders. “A unity government with criminals and terrorists? No thank you,” Rami el-Obeidi, a former intelligence officer for the post-Gaddafi government in Tripoli, told TIME on Thursday. “Lay down your arms first and give them all to the army. Then we can talk.”
That lack of a peace deal in Libya leaves a dangerous vacuum in the country — and the continued possibility of further attacks elsewhere in the region. “The reality is that the longer the protracted dialogue goes on the longer ISIS militants can exploit the security situation,” Sinkez said. “That is at the heart of this: the failure to agree on a way forward.”
This year has made clear just how tragic the consequences are of Libya’s political impasse. Until recently, Tunisia was one of the biggest sources of foreign fighters to jihadist groups in Syria — by some estimates, about 2,500 Tunisians have fought with jihadist groups since the conflict erupted in 2011. But Sinkez said the Tunisian militants’ tactics appear to have shifted this year to staying closer to home. “Libya after the  revolution was just a stopover point for people going to Syria,” he said. “But especially since 2015 rather than just going to fight against Bashar Assad, they are seeing a way to take a stronger role in North Africa.”
Libya still plays a key role, however. El-Obeidi, who travels in and out of eastern Libya, said he believes that as Haftar’s forces have increasingly waged attacks against ISIS positions, ISIS groups are moving around Libya, rather than basing themselves in fixed positions in the country’s vast southern desert. “They are mobile today,” he said. “To train people in shooting an Kalashnikov, and it give them some psychological training, that does not need a camp.”