The local officials in eastern Nangarhar province confirm that the coordinated attack on Customs Department in Jalalabad city ended with the elimination of the remaining six militants.
Terrified employees flung themselves from windows to escape as security forces battled the attackers for more than four hours, before all eight assailants were killed, Khogyani said.
There was no immediate claim of responsibility of today's blasts.
It was the latest deadly violence to strike Afghanistan as militant groups step up attacks and US-backed Afghan forces intensify air strikes and ground offensives.
Jalalabad is the capital of restive Nangarhar, which borders Pakistan.
Security forces and attackers are now fighting each other.
Earlier, health department officials in the city said hospitals had received at least four dead bodies and 20 wounded people.
Last month, an Islamic State suicide bomber killed at least 57 people, including women and children, and wounded 119 outside a voter registration centre in the Afghan capital Kabul in the latest attack on election preparations.
At the same time, Taliban fighters have stepped up the pressure on government forces across the country, from Baghlan province in the north, where they seized a district centre last week, to Farah in the southwest or Ghazni, south of Kabul.
Heavy security forces arrived at the spot of the attack.
The Taliban and IS have made clear their intention of disrupting the elections.