Daesh has claimed responsibility for twin suicide bombings in the head offices of Libya's electoral commission in Tripoli, the group's AMAQ news agency said Wednesday.
At least 12 people were killed when attackers stormed the building and set fire to it.
Videos posted on social media showed thick black smoke billowing from the building.
The group did not provide any evidence for its claim.
The ministry said in a statement that 12 people were killed and another two were wounded.
Militant groups are opposed to democratic elections and have targeted them in other countries.
The U.N. mission to Libya condemned the attack, saying violence "will not deter Libyans from moving forward in the process of establishing national unity and the rule of law and institutions."
Libya was plunged into chaos following the 2011 uprising that toppled and killed Moammar Gadhafi, and is now split between rival governments, each backed by an array of militias. A U.N.-backed government is based in Tripoli.
Earlier this week, the international Quartet trying to help bring order to Libya said it supports holding presidential and parliamentary elections this year, and will provide observers and electoral assistance to ensure the voting is free and fair.
In a joint statement following a meeting in Cairo on Monday, the European Union, the African Union, the Arab League and the United Nations said Libyans must commit in advance to respect and abide by the results and avoid violence or intimidation.