Gunmen struck Kabul University's campus on Monday, killing at least 19 people, trading fire with security forces and injuring more than 20 others, according to the country's Interior Ministry.
In the melee, three attackers were also killed, Interior Ministry spokesperson Tariq Arian said, adding that the incident was now over.
Download the NBC News app for the latest news on the coronavirus
Earlier Monday, Arian said that multiple attackers had entered the campus and were fighting with security forces.
First Vice President Amrullah Saleh appeared to blame the attack on the Taliban, despite the militant group denying that their fighters were involved in the assault.
"The Talibs ... won't be ever able to wash their conscience of this stinking and non-justifiable attack on Kbul uni," Saleh tweeted.
Witnesses said students had fled from the Kabul University campus.
"Almost all students have now left," Nahid, a student who asked that only her first name be used for security reasons, told Reuters by telephone after running away from the university.
Violence has plagued Afghanistan while government and Taliban negotiators have been meeting in Qatar to try to broker a peace deal that would allow the United States to bring home its troop and end its longest war.
The attack comes less than a week after the U.S. envoy for Afghanistan noted commitments to lowering violence had failed.
At the time he implored the Kabul government and Taliban insurgents to work harder toward forging a ceasefire at their peace talks.