Kabul, Afghanistan - 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 on Thursday, before the assault ended when two gunmen were shot dead.

The attack began at around 6:30 p.m. (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.

Sporadic gunfire could be heard through the night and, before dawn, police said the operation had concluded after they killed at least two attackers.

There was no claim of responsibility for an attack in which Kabul police chief Abdul Rahman Rahimi said seven students, three policemen and two security guards were killed, the second incident involving the university this month.

President Ashraf Ghani called the assault “a cowardly attempt to hinder progress and development in Afghanistan”.

“Attacking educational institutions and public places and targeting civilians will not only fail to shake our determination, but will further strengthen it to fight and eradicate terror,” he said in a statement.

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 Ghani.

One Ugandan man - a faculty member - was among the wounded, according to a list at the Kabul emergency hospital.

In a statement, the university said it was working with authorities to make sure everyone was accounted for.

“My number one priority at this point is the safety and security of all faculty staff, and students,” said Mark A. English, the university president.

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 the children of Afghanistan’s elite.

Afghan security forces inspect after a complex attack on the American University of Afghanistan in Kabul, Afghanistan, Thursday, Aug. 25, 2016. The attack has ended, a senior police officer said Thursday, after several people were killed. Kabul police Chief Abdul Rahman Rahimi said the dead included one guard, and that about 700 students had been rescued. (AP Photo/Rahmat Gul)Afghan security forces inspect after a complex attack on the American University of Afghanistan in Kabul, Afghanistan, Thursday, Aug. 25, 2016. The attack has ended, a senior police officer said Thursday, after several people were killed. Kabul police Chief Abdul Rahman Rahimi said the dead included one guard, and that about 700 students had been rescued. (AP Photo/Rahmat Gul)

DESPERATE ESCAPES

Terrified students recounted barricading themselves in classrooms or jumping from windows to escape.

“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.

Others said they scrambled toward an emergency exit, scaled walls and jumped to safety.

The university buildings are protected by armed guards and watchtowers but the gunmen still got in.

Edrees Nawabi, another student at the university, said he had long been concerned about campus security.

“We were scared but also we wanted to be educated,” he said.

It was the second time this month that the university or its staff had been targeted.

Two teachers, an American and an Australian, were abducted at gunpoint from a road near the university on Aug. 7. They are missing.

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 the 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 foreign troops remain to train and assist Afghan forces, while several thousand other 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.‎

Afghan men walk towards an ambulance after they were rescued from the site of an attack at American University of Afghanistan in Kabul, Afghanistan August 24, 2016. REUTERS/Mohammad Ismail   Afghan men walk towards an ambulance after they were rescued from the site of an attack at American University of Afghanistan in Kabul, Afghanistan August 24, 2016. REUTERS/Mohammad Ismail