A group of militants including suicide bombers stormed the head offices of Libya's electoral commission in Tripoli on Wednesday, killing at least 12 people and setting fire to the building, officials said.
Security forces engaged in a gun battle with the assailants as they tried to regain control of the building, said electoral commission spokesman Khaled Omar, who fled the offices with other staff as the attack unfolded.
There was no immediate claim of responsibility for the attack, but it appeared aimed at derailing efforts to organise elections in Libya by the end of this year, part of a U.N.-led attempt to unify and stabilise the country after years of conflict and political division.
The commission recently registered nearly one million new voters across Libya, though no date has been set for polls.
Wednesday's attack was the first of its kind in Tripoli for several years. Though security across Libya remains volatile, violence in the capital has recently been limited to localised clashes between armed groups.
Pictures posted on social media showed thick black smoke billowing from the site of the attack, in the Ghout al-Shaal district west of central Tripoli.
"I saw two suicide bombers myself... they were shouting Allahu Akbar (God is greatest)," said Omar, adding that he had seen bombers' body parts strewn on the ground.
"A suicide bomber blew up himself inside the commission and the others set a part of the building on fire."
The victims included three employees of the commission and four members of local security forces, Omar said. The health ministry put the toll at 12 dead and seven wounded.
Libya has been in a state of turmoil since a 2011 civil war resulted in the overthrow of longstanding ruler Muammar Gaddafi by rebel fighters backed by NATO air strikes.
Elections in 2014 were disputed, resulting in rival governments backed by competing military alliances in Tripoli and the east.
Militants linked to Islamic State have carried out suicide bombings across the north of the country in recent years, though the group lost most of its fighters in Libya when it was driven out of its stronghold in the central city of Sirte in 2016.
Libyan and Western officials say militants, including fighters loyal to Islamic State and al Qaeda, are now concentrated in remote desert areas, but also have sleeper cells in coastal cities including Tripoli.
Some Libyans and members of the international community have questioned the push for new elections this year, expressing concern about the lack of security as well as legal and logistical challenges.