Gunmen attacked Kabul University's campus on Monday, killing at least 19 people including students and trading fire with security forces, an Afghan government official and witnesses said.
At least 22 others were injured, according to the spokesperson for the Afghan interior ministry.
The attackers were targeting students and fired on them as they fled in the Afghan capital, one witness said.
“They were shooting at every student they saw,” Fathullah Moradi told Reuters, saying he had managed to escape through one of the university's gates with a group of friends.
The attack took place as the varsity was hosting a book fair attended by the Iranian ambassador to Afghanistan.
The Taliban said their fighters were not involved in the assault. No other group immediately claimed responsibility.
Witnesses said the attack followed an explosion in the area.
The attack ended after several hours with security forces killing three of the attackers, the interior ministry spokesperson said.
While Afghan officials declined to discuss the bookfair, Iran’s semiofficial ISNA news agency reported on Sunday that Iranian Ambassador Bahador Aminian and cultural attaché Mojtaba Noroozi were scheduled to inaugurate the fair, which would host some 40 Iranian publishers. Iranian state television reported the attack occurred, but did not offer information on its officials.
Iranian diplomats have been targeted previously by attacks in the country and nearly sparked a war between the two countries. In 1998, Iran held the Taliban responsible for the deaths of nine Iranian diplomats who were working in its consulate in northern Afghanistan and sent reinforcements to the 950-kilometre-long border that Iran and Afghanistan share.
Nato Senior Civilian Representative to Afghanistan Stefano Pontecorvo condemned the attack.
“This is the second attack on educational institutions in Kabul in ten days. Afghan children and youth need to feel safe going to school,” he said in a statement.
An attack late last month on an education centre in Kabul killed 24 people, mostly students.
Violence has plagued Afghanistan while government and Taliban negotiators have been meeting in Qatar to try to broker a peace deal and as the United States brings home its troops.
Pakistan condemns 'mindless attack'
Meanwhile, the Foreign Office (FO) condemned the "mindless attack" on the varsity. "This act of terrorism is particularly despicable as it targeted an institution of learning," the FO said in a statement.
"We extend our deepest sympathies and heartfelt condolences to the families of the victims and wish a speedy recovery to those wounded. Our thoughts and prayers are also with the Afghan people in this hour of grief and sorrow," the statement said.
Pakistan condemns terrorism in all its forms and manifestations and will continue to support a peaceful and stable Afghanistan, the FO added.