The exact date of the elections that should put an end to years of conflict and should unite the country, not installed yet.
Electoral commission spokesman Khaled Omar told Reuters that three officials and four security officers were killed in the attack.
The ministry strongly condemned the terrorist attack, expressing its wish for God's mercy upon those who lost their lives, a speedy recovery to the wounded, and conveyed condolences to the relatives of the deceased. They then set the building on fire and detonated the suicide vests they were wearing.
Pictures posted on social media showed thick black smoke billowing from the commission's offices, in the Ghout al-Shaal district west of central Tripoli.
No group has claimed responsibility but militants with links to the Islamic State group are believed to have maintained sleeper cells in Libya's coastal cities.More news: Kanye West says the "Taylor Swift moment" damaged his career
More news: FIFA Mulling Changes to Non-World Cup Competitions
More news: President Donald Trump nominated for 2019 Nobel Peace Prize
It added: "Such terrorist attacks will not deter Libyans from moving forward in the process of consolidating national unity and building a state of laws and institutions".
The commission had recorded two million new voters since last December in preparation for the country's next election. A UN-backed government is based in Tripoli.
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.
United Nations special envoy Ghassan Salame said in February he hoped for parliamentary and presidential elections in Libya by the end of 2018, but warned conditions were not yet ready for polling.