Security forces called to Radio Television Afghanistan in the city of Jalalabad were drawn into a long gun battle with the attackers.
Four employees of the TV station and two police officers were killed, Nangarhar province governor’s spokesman Atauolah Khogyani said.
Four of the five attackers were also killed, including one suicide bomber, he said. The fifth attacker was arrested.
ISIS claimed the attack in a message posted on the Telegram messaging service by the ISIS-affiliated media Amaq. CNN cannot independently verify the authenticity of the claim.
At least 19 people were injured in the attack, including seven who were treated in hospital and released, the provincial health services director, Najibullah Kamawal, said.
An explosion erupted from the area of the assault after the attackers entered the building, police said. Footage from the scene showed people running in panic as a barrage of gunfire rang out.
A crisis response team was called to the scene and searched the premises room by room.
Civilians are often targeted by militants in Afghanistan in bombings and shooting attacks.
In all, 3,498 civilians were killed and 7,920 injured in 2016 in Afghanistan, the UN Assistance Mission in the country reported. It marked the highest number of civilian casualties since the UN began documenting statistics in Afghanistan.
CNN’s Angela Dewan, Elizabeth Joseph and journalist Aleem Agha contributed to this report.