Security forces were called to the premises of Radio Television Afghanistan in the city of Jalalabad and were drawn into a long gun battle with the attackers.
Four of the five attackers have been killed, including one suicide bomber, the Nangarhar province governor's spokesman Atauolah Khogyani told CNN. The fifth attacker has been arrested and the situation is now over.
Of the two civilians killed, one was an employee of the television station, Khogyani said.
Police earlier described the attackers as insurgents, but it is not immediately clear who was behind the assault. Jalalabad has previously been hit by Taliban and ISIS attacks.
An explosion was heard from the vicinity after the attackers entered the building, police said, and footage from the scene showed people running in a panic as a barrage of gunfire rang out.
A crisis response team was called to the scene and searched the premises room by room.
At least 14 people were injured in the attack, the provincial health services director Najibullah Kamawal said, seven of whom have been treated in hospital and since released.