Twelve people -- seven students, three police and two security guards -- were killed in an attack by gunmen on the American University in the Afghan capital, Kabul, police said on Thursday.
Fraidoon Obaidi, chief of the Kabul police criminal investigation department, said 44 people were wounded, including 35 students.
Security forces killed two suspected militants to end the attack on the compound, which began on Wednesday evening with a large explosion followed by gunfire, a police official said earlier.
The attack comes just weeks after two university professors -- an American and an Australian -- were kidnapped at gunpoint near the school.
No group has so far claimed responsibility for the assault, but it occurred as Taliban insurgents ramp up their nationwide summer offensive against the Western-backed Kabul government.
“We have ended our clean-up operation. Two attackers were gunned down,” Obaidi said.
Local media reported that hundreds of students were rescued during the overnight operation, many of whom tweeted anguished messages for help, with some using classroom furniture to barricade the doors.
The attack started on Wednesday evening, when the private university is usually packed with students, many of them working professionals doing part-time courses.
“I heard explosions and gunfire is going on close by... our classroom is filled with smoke and dust,” an anxious student said over the phone, before fleeing the campus.
Authorities refused to confirm whether any hostages had been taken.
Nato military advisers were helping Afghan forces to respond to the attack, a US official said, without specifying how many troops were involved.
Many of the wounded were rushed into waiting ambulances outside the university on stretchers, as erratic gunshots rang out through the night from inside the complex.
“We send our thoughts and prayers to the families of those killed and our heartfelt wishes for a speedy recovery to those wounded,” the US national security council said in a statement, condemning the attack.
The elite American University of Afghanistan, which opened in 2006 and enrolls more than 1,700 students, is seen as a high-profile target for militants partly because it attracts foreign faculty members.
The two foreign professors at the university were seized from their vehicle on August 7, as the kidnappers smashed the passenger window and hauled them away at gunpoint.
It was apparently the first reported abduction related to a private university in Afghanistan.
Their whereabouts are still unknown and no group has claimed responsibility for the abductions, the latest in a series of kidnappings of foreigners in the conflict-torn country.
The Afghan capital is infested with organised criminal gangs who stage kidnappings for ransom, often targeting foreigners and wealthy Afghans, and sometimes handing them over to insurgent groups.