Seven students, three policemen and two security guards were killed in the attack on the American University campus, Basir Mujahid, the spokesman said.
Around 750 students were on campus at the time, he added.
Police searched the American University of Afghanistan in Kabul early Thursday and killed two attackers who stormed the campus with guns and explosives, Fraidoon Obaidi, chief of Kabul police's criminal investigation department, told AFP early Thursday.
"We have ended our clean-up operation. Two attackers were gunned down," Obaidi said about 10 hours after the assault began.
The gunmen detonated explosives and fired guns, witnesses said, causing some students and faculty to flee. Others hid inside buildings, a senior State Department official told CNN.
No group immediately claimed responsibility. The Afghan government and supporting US officials have battled the Taliban for years. Two professors were abducted recently.
Despite its name, few Americans study at the school, a senior US State Department official told CNN. But a number of Americans serve on the faculty and may have been trapped inside buildings. The school is regarded as a symbol of cooperation between Afghanistan and the United States.
Ahmad Samin said he was teaching a chemistry class Wednesday evening when the assailants struck.
The attackers opened fire and detonated explosives on the campus. Quickly, the lights went out in Samin's classroom.
"It was very dark, (and) everyone was running. Everyone started screaming," said Samin, who is a US citizen. "(It) was the scariest moment in my life. I was just thinking about my son and daughter who are in (the United States)."
Amid black smoke, he took off running with the students and other faculty, and "the smoke entered my mouth" as he fled, he said.
'Enormous and harsh sound'
Witnesses described a chaotic scene.
A student, who asked to remain anonymous out of fear for his safety, told CNN he was attending a lecture class when he heard a "very enormous and harsh sound" -- an explosion roughly 50 meters from his classroom.
"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."
He heard gunfire as they ran, then a second explosion. Both explosions came from the school's entrance, he said.
"People were screaming for help. Everyone was screaming," he said.
He saw several people injured -- some from glass, others by bullets. A guard had injuries that appeared to be a result of one of the explosions, he said.
The student said he had heard from friends trapped in three buildings.
Bilal Sawary, a journalist in Kabul, said he'd heard from several people on campus.
"One of my family members who was there told me the attackers had maps, they were drinking Red Bulls, clearly aiming to stay as long as they could and some of them were tossing hand grenades," he said.
Security fears in Kabul
The school opened in 2006. It's the only private, nonprofit coed university in the country and has about 1,700 full- and part-time students.
The university is a very close partnership between the United States and Afghanistan and is an important symbol of the partnership between the two countries, the State Department official said.
It is considered an elite school that represents the modern and moderate Afghanistan, where many afghan government and nongovernment organization officials have studied. The United States funds a lot scholarships for Afghans to study, including many for women.
The blast occurred at 7:50 p.m., when students were gathering and eating together.
It comes less than three weeks after the school was forced to suspend campus operations after two teachers -- an American and Australian -- were kidnapped at gunpoint. Their whereabouts remain unknown.
A rash of kidnappings and Taliban bombings have heightened security fears in Kabul, the Afghan capital. American and other diplomats have been barred from traveling by road the short distance from the city's international airport to their diplomatic missions. Instead, they've been ferried by helicopter.
Many countries, including the United States and United Kingdom, have longstanding travel advisories against all but essential travel to Afghanistan because of the security situation.
"We are closely watching the situation at the American University in Kabul," a U.S. defense official told CNN. "A small number of advisers from the Resolute Support Mission
is currently assisting Afghan forces as they respond. These advisers are not in a combat role; they are advising their Afghan counterparts."
The National Security Council issued this statement on Wednesday: "The United States condemns in the strongest terms the terrorist attack today on the American University of Afghanistan. We salute the quick work of the Afghan National Defense and Security Forces who responded to the attack and secured the university. We send our thoughts and prayers to the families and loved ones of those killed and our heartfelt wishes for a speedy recovery to those wounded. We further reaffirm the support of the United States for the Afghan government and people as they continue to build a more stable, secure, and prosperous Afghanistan."