A spokesman for the Afghan interior ministry said the attack was eventually stopped when three gunmen were killed.
At least 22 people were wounded, the interior ministry said.
The attack began around the time government officials were expected to arrive at the campus for the opening of an Iranian book fair.
All of the dead were students, including 10 women, a Kabul police spokesman told the AFP news agency.
The Taliban denied involvement and condemned the attack.