The assault was carried out by several "terrorist attackers", according to the Libyan unity government's official TV channel, which cited foreign and interior ministry sources.
Plumes of smoke were seen rising from the building, witnesses said.
There was no immediate casualty toll or claim of responsibility.
Torn apart by power struggles and undermined by chronic insecurity, Libya has become a haven for jihadists since the ouster and killing of Moamer Kadhafi in 2011.
The Islamic State group took advantage of the chaos to gain a foothold in the coastal city of Sirte in 2015.
Forces loyal to the UN-backed Government of National Accord (GNA) regained control of the city in December 2016 after eight months of deadly fighting.
Since then, some jihadists have returned to the desert in an attempt to regroup and reorganise.
In September, IS claimed responsibility for a suicide attack on the headquarters of Libya's National Oil Company in the heart of Tripoli which left two dead and 10 wounded.
Four months earlier, it claimed an attack on the electoral commission's headquarters which left 14 dead.