Ismail Kawosi, a spokesman for the ministry of public health, said 41 people had been killed and 48 wounded in the latest in a series of attacks on media organizations in Kabul.
The attack, which involved at least three explosions, occurred during a morning panel discussion on the anniversary of the Soviet invasion of Sunni-majority Afghanistan at the Tabian Social and Cultural Centre, with many of those attending students, witnesses said.
It was also the latest in a series of attacks on Shi'ite targets by the ISIS, which claimed responsibility in an online statement.
The floors of the centre, at the basement level, were covered in blood as wailing survivors and relatives picked through the debris, while windows of the news agency, on the second floor, were all shattered.
People running outside into the compound following an initial blast inside were caught by two further explosions which caused heavy casualties, witnesses said.
Photographs sent by witnesses showed serious damage at the building, in a heavily Shi'ite area in the west of the capital, and a number of dead and wounded on the ground.
Deputy Health Minister Feda Mohammad Paikan said 35 bodies had been brought into the nearby Istiqlal hospital. Television pictures showed many of the injured suffered serious burns.
President Ashraf Ghani's spokesman issued a statement calling the attack an "unpardonable" crime against humanity and pledging to destroy terrorist groups.
The bloodshed follows an attack on a private television station in Kabul last month, which was also claimed by the ISIS.
Backed by the heaviest US air strikes since the height of the international combat mission in Afghanistan, Afghan forces have forced the Taliban back in many areas and prevented any major urban centre from falling into the hands of insurgents.
But high-profile attacks in the big cities have continued as militants have looked for other ways to make an impact and undermine confidence in security. ISIS, which is opposed to both the Taliban and the Western-backed government, has claimed a growing share of such attacks.
"This gruesome attack underscores the dangers faced by Afghan civilians," rights group Amnesty International said in a statement from its South Asia Director, Biraj Patnaik. "In one of the deadliest years on record, journalists and other civilians continue to be ruthlessly targeted by armed groups."
According to a report this month by media freedom group Reporters without Borders, Afghanistan is among the world's most dangerous countries for media workers with two journalists and five media assistants killed doing their jobs in 2017, before Thursday's attack.
According to Sayed Abbas Hussaini, a journalist at Afghan Voice, one reporter at the agency was killed in Thursday's attack and two were wounded.
(Reporting by Abdul Aziz Ibrahimi; Writing by James Mackenzie; Editing by Nick Macfie)