Twelve people, including seven students, were killed in an attack on the American University in Kabul that sent hundreds of students fleeing in panic, police said early on Thursday, before the assault ended when two gunmen were shot dead.
The attack began at around 6:30 p.m. local time (1400 GMT) on Wednesday with a large explosion that officials said was a car bomb followed by gunfire, as suspected militants battled into the complex where foreign staff and pupils were working.
Elite Afghan forces surrounded the walled compound and eventually worked their way inside, according to a senior interior ministry official.
Kabul police chief Abdul Rahman Rahimi said seven students, three policemen and two security guards were killed during the attack, the second incident involving the university this month.
Sporadic gunfire could be heard through the night and, before dawn, police said the operation had concluded.
"The fight is over and at least two attackers are killed," a police official at the scene told Reuters. "Right now a clearance operation is ongoing by a criminal technique team."
The Afghan Public Health Ministry said no foreigners were reported among the wounded.
Students walk toward a police vehicle after they were rescued from the site of an attack at the American University of Afghanistan in Kabul, Afghanistan August 25, 2016.
Fraidoon Obaidi, chief of the Kabul police Criminal Investigation Department, told Reuters that police had evacuated between 700 and 750 students from the university, which is popular with Afghanistan's elite.
Terrified students recounted barricading themselves in classrooms or jumping from the second floor in order to escape. Most appeared to have got away.
"Many students jumped from the second floor, some broke their legs and some hurt their head trying to escape," Abdullah Fahimi, a student who escaped, told Reuters. He injured his ankle making the leap.
"We were in the class when we heard a loud explosion followed by gunfire. It was very close. Some students were crying, others were screaming," he said.
Ahmad Mukhtar, who also fled, said the gunmen had got into the university buildings despite security measures including armed guards and watchtowers.
"I finished my class and was about to leave when I heard a few gunshots and a huge explosion, followed by more gunfire," he said. "I ran toward the emergency exit with other students, climbed the wall and jumped outside."
Islamist militant groups, mainly the Afghan Taliban and a local offshoot of Islamic State, have claimed a string of recent bomb attacks aimed at destabilizing Afghanistan and toppling the Western-backed government of President Ashraf Ghani.
No one has taken responsibility for the university raid.
It was the second time this month that the university or its staff had been targeted.
Afghan security forces arrive at the site of an attack at American University of Afghanistan in Kabul, Afghanistan August 24, 2016.
Two teachers, an American and an Australian, remain missing after being abducted at gunpoint from a road nearby on Aug. 7.
The American University of Afghanistan has about 1,700 students and advertises itself as the country's only not-for-profit, "non-partisan", co-educational university. It opened in 2006 and caters to full-time and part-time students.
Taliban insurgents control large swaths of Afghanistan, and Afghan security forces are struggling to contain them, especially in the provinces of Helmand to the south and Kunduz to the north.
NATO ended its combat mission in December 2014 but thousands of troops remain to train and assist Afghan forces, while several thousand more U.S. soldiers are engaged in a separate mission focusing on al Qaeda and Islamic State.
The United States said it was closely monitoring the situation in Kabul following the university attack and that forces from the U.S.-led coalition were involved in the response in an advise-and-assist role.
State Department spokeswoman Elizabeth Trudeau said the U.S. Embassy was working to account for all of its personnel and to locate and assist any U.S. citizens affected by the attack.