The bloodshed comes as the international community pushes for elections it hopes will help calm the turmoil that has plagued the north African country since the 2011 ouster of dictator Muammar Gaddafi.
Two armed assailants attacked the electoral commission building, shooting guards and officials before blowing themselves up, interior minister Abdelsalam Ashour told a news conference on Wednesday.
The internationally backed Government of National Accord denounced “the cowardly suicide attack” and pledged its “commitment to the democratic process”.
At least 12 people were killed and seven wounded, according to the health ministry.
Two policemen were among those killed, the interior ministry said.
Eyewitnesses earlier said shots and at least two explosions were heard, while black smoke could be seen rising from the commission headquarters.
Isis issued a statement claiming the attack, which it said was in response to a call by its spokesman this month to target polling stations in the Middle East.
The United Nations mission in Libya condemned the assault and extended condolences to victims’ families.
“Such terrorist attacks will not deter Libyans from moving forward in the process of consolidating national unity and building the state of law and institutions,” it said on Twitter.
France and Britain condemned the attack, which British foreign minister Boris Johnson called “despicable”.
The US State Department issued a statement “strongly” condemning the bombings: “This terrorist attack against a key pillar of Libya’s fragile democracy only deepens the United States’ commitment to support all Libyans as they prepare for credible and secure elections.”
More about: #Libya