At least 22 people were killed when attackers stormed one of Afghanistan's main universities on Monday, detonating a suicide bomb and spraying classrooms with bullets in a brazen hours-long assault claimed by Islamic State group.
The attack on Kabul University, which came as violence surges across Afghanistan, marked the second time in less than two weeks that an educational institution was targeted in the capital by IS extremists.
Survivors described horrific scenes after a suicide bomber struck inside the campus around 11:00 am (0530 GMT).
Two gunmen then opened fire, officials said, sending hundreds of students fleeing and scrambling over perimeter walls.
Fraidoon Ahmadi, a 23-year-old student, told AFP he was in a university class when gunfire broke out.
"We were very scared and we thought it could be the last day of our lives... boys and girls were shouting, praying and crying for help," Ahmadi said.
He said he and other students were besieged for more than two hours before being rescued.
Images posted online showed what appeared to be the bodies of slain students lying by desks and chairs.
"They opened fire... all my classmates were lying in blood, either dead or wounded," one student told a local television channel, adding that he escaped by climbing out a window.
IS said two of its fighters carried out the late morning attack.
"Two Islamic State fighters managed to attack a gathering set up by the Afghan government at the Kabul University for the graduation of judges and investigators after completing a course at the university," the group's propaganda arm Amaq said.
"The two fighters targeted the graduates with automatic weapons... then clashed with security forces."
The Ministry of Public Health said at least 22 people were killed and 22 more wounded. Officials said most of the casualties were students.
- Ghani vows revenge -
It was not immediately clear how the attackers got their weapons into the university, which has security checks.
Officials said an investigation was under way.
It took Afghan security forces, supported by US troops, several hours to clear the campus and declare the attack over.
The Taliban said they were not involved, but Vice President Amrullah Saleh blamed the insurgent group and their supporters in Pakistan, even as he acknowledged an intelligence failure.
We "will correct our intelligence failures. But the Talibs, their like minded satanic allies in the next door won't be ever able to wash their Conscience of this stinking & non justifiable attack on Kbul uni," Saleh wrote on Twitter.
Afghan authorities routinely accuse Islamabad of backing the Taliban, charges Pakistan denies.
Pakistan's foreign ministry condemned Monday's attack what it said was a "despicable" assault on a seat of learning.
At the United Nations, Secretary General Antonio Guterres said he "strongly condemns the horrific attack" at the university.
"This appalling attack, the second in 10 days on a school facility in Kabul, is also an assault on the human right to education," Guterres said in a statement.
In a statement, President Ashraf Ghani vowed to "take revenge for this senseless attack and for any drop of innocent students' blood spilled today."
He added that the attack "will not remain without response, we will retaliate."
Authorities declared Tuesday as a day of national mourning.
- Surging violence -
Several education centres have been attacked over the years by extremist groups such as Islamic State.
Last week at least 24 people, mostly students, were killed in a suicide attack on an educational centre in western Kabul that was claimed by IS.
In 2018, a suicide bomber killed dozens of people, many of them teenagers, in front of Kabul University in an attack also claimed by IS.
NATO in Afghanistan condemned the latest carnage.
Violence has surged in recent weeks despite ongoing peace talks between the Taliban and the government that started in Qatar in September.
Zalmay Khalilzad, the US envoy who negotiated a separate deal with the Taliban in February, visited Islamabad on Monday where he met with the head of the Pakistan military to discuss a "way forward for lasting peace in Afghanistan", officials said.
Talks have so far made little tangible progress.