Gunmen, who set fires and detonated explosives, were said to have killed several people and attempted to destroy records linked to a vote set for later this year.
Gunmen stormed Libya’s electoral commission in the capital, Tripoli, on Wednesday, spraying bullets and then detonating explosives in a suicide attack that claimed several lives.
“They shot with their machine guns, set the building on fire, before blowing themselves up,” said Khalid Omar, a spokesman for the electoral commission, who witnessed part of the attack.
Mr. Omar said he knew of six co-workers who had been killed, but he added that the head of the commission had told him that there were 10 dead. There were reports that some members of Libya’s security forces, who exchanged gunfire with the attackers, had also been killed.
The toll could be higher, Mr. Omar said, because “there are a lot of people whom we couldn’t reach and because of the chaotic nature of all this.”
The Islamic State group claimed it had carried out the attack.
Mr. Omar said that heavily armed men — he said that he did not know the precise number, but had seen two — took over the commission’s administration building, one of several structures in the complex.
“They were very close to us, some 20 meters or so, they were armed with machine guns,” he said, adding that they “went through the building and didn’t let anyone move.”
“Meanwhile, a security force came and besieged the building,” he said.
The gunmen apparently had suicide vests, which they detonated as security forces closed in. Images posted on social media showed smoke billowing from the building.
Libya has been torn by war and terrorism since the 2011 uprising that overthrew the dictator Muammar el-Qaddafi. Elections are planned for later this year, but some opponents of the government have been determined to disrupt the process.
“My understanding is that there were two or three attackers who moved in on the administrative building,” said Otman Gajiji, a former chairman of the electoral commission. “One of them went upstairs and started setting the selections materials on fire, while a second one was downstairs providing cover. It seems that their target was the elections materials stored in the administrative building.”
Armed political factions and Islamist militias are a force in Libya, and the central government has no control over some parts of the country. Gen. Khalifa Hifter, the 75-year-old military commander who had emerged as the nation’s strongest figure, has been seriously ill, raising fears that his death could lead his forces to splinter, making the situation even more chaotic.
The attack on the electoral commission “sends a very bad signal, locally and internationally,” Mr. Gajiji said. “We want to hold elections, but it’s hard to implement on the ground, especially with security not being controlled by the state.”