Two years of turmoil since the Arab Spring and some of the toughest terms in the business have led international oil companies to reassess their role in North Africa, with U.S. firms looking keenest to leave.
Libya and Algeria are among Africa's top four oil producers. Together with Egypt, they are major suppliers of gas to Europe and their budgets depend heavily on energy revenues.
But Libya has not turned into the bonanza some foreign oil firms had hoped for, while the cost to reward ratio of producing gas in Egypt and Algeria looks less appealing as new finds in more politically stable places like Tanzania offer alternatives.
For some U.S. companies, the prospect of shedding non-core assets and cashing in on the shale gas boom at home seems increasingly attractive, analysts say.
At least seven firms, five of them American, have abandoned projects, frozen activities or sold stakes worth billions of dollars in Libya, Algeria and Egypt in the past 18 months alone.
"The politics of the Middle East and North Africa have made things more difficult for all companies but American companies are not tied to North Africa," said John Hamilton, North Africa analyst at Cross-border Information.
"That's in contrast to companies like Repsol, Eni, Total and even BP. For them, these are large deposits on their door step so it makes more sense for them to stick it out."
"For ExxonMobil, why bang your head against a brick wall in Libya, spend a fortune on dry wells and deal with the political situation that is so complex? If you can go elsewhere and get a good return for less political risk then why not?"
A 'TOXIC COCKTAIL'
Exxon said in September it was scaling back in Libya, while Royal Dutch Shell abandoned two exploration blocks there last year. Both had made disappointing finds.
Others have been slow to resume exploration since the 2011 war. Those that are heavily invested have paid the price.
A mix of labor strikes, militias and political activists have blocked several oil fields and ports since the end of July.
Repsol and Eni, involved in western Libya, have seen output largely restored since fields reopened last month. But companies invested in eastern Libya are entering a third month of closures at several important export terminals.
Even before the closures, it emerged that Marathon Oil would sell its stake in Waha Oil Co., a consortium with Libya's National Oil Corp. and two other U.S. firms.
"Libya is an expensive place to do business. To justify the tough terms, oil firms needed very good finds but even before the revolution, exploration results in general had not met expectations," said Beth Hepworth, co-director of Frontier Research and Advisory, which also publishes Libya Monitor.
"Couple that with the deteriorating security environment after 2011 and the uncertainty over the political roadmap, and you get a toxic cocktail."
Keen to keep foreign energy firms on board, the government is revising terms for existing investors and promising better returns in the next licensing round due next year.
But analysts say Libya will not realistically be able to offer new blocks until production is largely restored. And the oil sector has become a political hostage, repeatedly held to ransom by armed groups pressing local or political interests.
"It all comes back to politics," said Hepworth. "If you are a big company you might decide to wait for more visibility."
CONTRACTS, OBLIGATIONS, INVESTMENTS
In neighbouring Algeria, an attack on a gas plant in the Sahara desert in January triggered an exodus of expatriate workers and forced energy companies to ramp up security. But terms were already so tight that there was little appetite among international oil companies in the last licensing round.
U.S. ConocoPhillips said last year it would sell its Algerian unit to Indonesia's Pertamina for $1.75 billion. Hess is selling one of its two Algerian oil stakes to Cepsa, which is already heavily involved there, and Britain's BG Group also plans to go, sources said in April.
The government passed an amended hydrocarbons law in January but industry sources said the changes were not enough to counter the prospect of higher security costs after the In Amenas siege.
In Egypt, two years of upheaval have hit government coffers, raising concerns that it cannot pay existing firms to produce its gas let alone entice investors to develop new finds. It plans to compensate the firms but that comes too late for some.
Apache Corp. said in August it had sold its Egyptian business to Sinopec for $3.1 billion, due to investor concerns over its exposure there. Apache has sold non-core assets globally to focus on U.S. onshore production.
But for companies that are heavily invested in production, the decision to go is not as easy as it was for Exxon or Shell, which were exploring. For all those that have left, for many investors, particularly Europeans, it makes sense to stay on.
Statoil and BP did not abandon Algeria after the attack on their joint venture at In Amenas. Libya's oil minister said this week that Eni, the top foreign oil company in Africa by volume, was committed to Libya and BP would resume its actitivity soon.
Germany's Wintershall, involved in the Mabrouk joint venture, said leaving Libya, where it has been active since 1958, was not a topic of discussion.
"You are not in a position to say: This isn't fun anymore so we will leave. You have contracts, obligations, billions of dollars worth of investments," said a senior executive of a major energy company working in Egypt. "We don't believe Egypt is going to go the Syria route."
© 2016 Thomson/Reuters. All rights reserved.