Wednesday's deadly suicide bombing of Libya's election commission is the most sophisticated terror attack the country has suffered since 2015. And analysts say it underlines the dangers Libya will need to navigate in the months ahead as divided authorities, encouraged by the United Nations, seek to hold a nationwide poll.
Islamic State's Amaq propaganda wing claimed responsibility for the blast, which left at least 12 dead, and involved three gunmen, two of whom blew themselves up, saying the bloodletting in the capitol, Tripoli, was part of a campaign to target polling stations.
For weeks the proposed elections have prompted the doubts of some political observers and analysts, who fear the country isn't stable or secure enough to be holding polls and that trying to do so would invite efforts to derail it — either from jihadists or militias fearing their power will be undercut.
Last month, Human Rights Watch warned against rushing Libya to the polls, while the country remains mired in violence and divided between warring factions featuring rival governments and an array of militias, some ideological, some town-based.
The rights group warned that neither the internationally-recognized government in Tripoli nor authorities in the east, led by the renegade General Khalifa Haftar, can guarantee freedom of assembly or free speech essential for any credible vote.
"Libya today couldn't be further away from respect for the rule of law and human rights, let alone from acceptable conditions for free elections," said Eric Goldstein, deputy Middle East and North Africa director for the rights group.
The last parliamentary elections in Libya in 2014 led to rival governments being set up in Tripoli and the east, backed by competing and shifting armed alliances.That election saw a very low turnout with only 630,000 people voting out of a registered electorate of 2.5 million.
Most voters didn't bother to go to the polls, analysts and Libyans said at the time, because they despaired anything would be changed by doing so and feared the country would just continue to be engulfed by the lawlessness and disorder it has seen since the 2011 popular uprising that toppled Libyan autocrat Colonel Moammar Gadhafi.
The United Nations mission in Libya condemned Wednesday's suicide bombing on Twitter and extended condolences to the families of the dead.
Five successive United Nations envoys have tried to oversee a deal between warring factions in the fractious country, but to little avail.The current envoy, Ghassan Salame, told the U.N. Security Council last month that working towards free and credible elections in Libya to be held this year was a "top priority."
He hopes elections will edge the country back to stability and end the impasse between rival governments and militias. The election commission in recent weeks has been registering voters and its officials say the registrations are secure, thanks to a back-up database. The election process has already seen the assassinations of a string of self-declared electoral candidates.
Emadeddin Muntasser, a Libyan human rights activist and political analyst, fears the latest U.N. plan backed by Western powers will fail.
"With elections only a few months away, the U.N. has not addressed the lack of security or the lack of basic freedoms in areas controlled by various warlords," he argued in a policy paper published by the Atlantic Council, a New York-based research group.
Muntasser says the best way forward would be for incremental elections to be held with towns signing up as they see fit and sending representatives to a new parliament that slowly emerges and starts in an evolutionary way to stabilize the country.
Other analysts argue the U.N. has little choice but to try to press on with an election, arguing a nationwide poll provides the best opportunity for Libyans to end the disorder.
The bombing and gunfire that erupted Wednesday may also herald a new phase in IS efforts to remain relevant and dangerous in the North African state and reflects the difficulty of rooting out jihadists, who have suffered setbacks in Libya.
Islamic State had controlled the coastal city of Sirte, hoping to use it as a launchpad for attacks in Libya and in neighboring states. But it was driven out by forces loyal to the United Nations-backed prime minister, with the assistance of U.S. airstrikes and Western special forces.
It took a nearly three-year-long effort for General Haftar to oust extremist militias from Benghazi, Libya's second city. And the eastern town of Derna is still occupied by an Islamist militia known as the Shura Council of Mujahideen. Jihadist elements also remain lodged in the southwestern city of Sebha.