Libya violence: Twelve killed in Tripoli election HQ attack
At least 12 people have been killed and several injured in an attack on Libya's electoral commission headquarters by the Islamic State group (IS).
At least one suicide bomber blew himself up while other armed assailants stormed the building in the capital, Tripoli, and set it on fire.
Voters have been registering for elections expected later this year.
IS offered no proof to back its claim of carrying out the attack - the first of its kind in recent years.
It is one of several militant groups active in Libya, which has been in constant turmoil since Muammar Gaddafi was ousted in 2011.
After his 42-year rule, the country was split between myriad rival armed groups, loyal to one of three governments.
Although many observers have questioned whether an election can be secured in the politically and militarily divided country, the international community appears hopeful that it would give the troubled North African state a fresh start.
- Updates on this and the rest of Africa's news
- How realistic are Libya's election plans?
- Why is Libya so lawless?
Electoral commission spokesman Khaled Omar told Reuters that three officials and four security officers were killed in the attack. The health ministry later put the number of dead at 12.
Mr Omar said he saw the attackers, including two suicide bombers, storm the building and spotted bombers' body parts strewn on the ground.
He added that security officers had entered the building to respond to the attack in the Ghout al-Shaal district west of central Tripoli.
IS was once a powerful force in Libya, operating from its stronghold city of Sirte. The group was driven from the city in late 2016. But it is believed to have maintained sleeper cells in the coastal cities.
No date has been set for elections, but the electoral commission has been registering potential voters in preparation for a poll that could come this year.
Speaking at a news conference, the head of the commission said that voter registration records were safe, and copies had been made.
The United Nations - which backs a unity government based in Tripoli - said the attack "will not deter Libyans from moving forward".
Analysis: Attack sends strong message against election
By Rana Jawad, BBC North Africa correspondent
This attack is the deadliest and most elaborate of its kind in Tripoli in at least three years.
It may not come as a surprise, given Libya's precarious security conditions, but it will still have sent shockwaves around Tripoli because of the target and its reported victims, which included election commission employees.
In the past, attacks in the capital have mostly been confined to targeting security forces linked to the state or militias, as well as diplomatic mission buildings and foreigners.
The tactics used are reminiscent of the deadly attack on the Corinthia hotel in 2015 - in which nine people were killed.
The target appears to crystallise a political message on the future of the country and attempts to move forward.
But targeting the core symbol of that expected change for the country will not be taken lightly.