Afghan security forces arrive at the site of an attack at American University of Afghanistan in Kabul, Afghanistan August 24, 2016.Reuters

At least 12 people — seven students, three police personnel and two security guards — were killed early Thursday morning in an attack by gunmen on the American University of Afghanistan located in Kabul.

Security forces shot dead two attackers almost 10 hours after the siege began with an explosion around 7:50 p.m on Wednesday. About 50 people, including 35 students and nine police officials, were wounded in the attack while over 750 students and staff members, who were trapped inside the university campus, were rescued.

Police searched the premises on Thursday morning and shot dead the two attackers who had stormed into the campus with guns and explosives, Fraidoon Obaidi, chief of Kabul police's criminal investigation department, told AFP.

"We have ended our clean-up operation. Two attackers were gunned down," Obaidi said. Special Forces along with American military were deployed at the scene.

No terrorist organisation has claimed responsibility for the attack yet. Afghanistan has been fighting against the Taliban for years with the support of the United States. The U.S. State Department condemned the attack, calling it "an attack on the future of Afghanistan."

The university, which is considered a symbol of cooperation between Afghanistan and the U.S., has several American faculty members.

Massoud Hossaini, a Pulitzer Prize-winning photojournalist for the Associated Press, was among those trapped inside the building. He was in one of the classrooms when the attack happened and tweeted for help. He later managed to escape along with nine other people through the northern emergency gate.

"I went to the window to see what was going on, and I saw a person in normal clothes outside. He shot at me and shattered the glass... As we were running, I saw someone lying on the ground face down. They looked like they had been shot in the back," Hossaini told the AP, adding that they had barricaded themselves in the classroom, where attackers had thrown two grenades, wounding several of his classmates.

"Everyone looked around the room looking for an escape," he said. "We have an emergency exit area in the corner of the campus. It's like a gate that opens when people need to get out of campus. Everyone was running out of there," a student, who wished to remain anonymous, told CNN, adding that he was attending a lecture when he heard a "very enormous and harsh sound."

The attack comes two weeks after two members of the university staff, an American and an Australian, were abducted from the campus by unidentified gunmen.

The non-profit private university opened in 2005 and currently has a strength of around 1,700 students. They university offers courses in English, adult professional qualifications and bachelor degree programmes, among others. Several students are adults, who study part-time.