The attack, which was claimed by the Islamic State group, targeted students leaving the Marshal Fahim National Defense University in western Kabul.
Kabul police spokesperson Firdaws Faramarz said the suicide bomber had been on foot. He blew himself up when a soldier challenged him near the entrance to the war college.
"In the blast, 16 people were wounded and six were martyred," Faramarz said.
The attacker "detonated himself before reaching his target", he added, without providing further details.
The attack happened around noon (0730 GMT), a time when students typically leave school early during the month of Ramazan.
Afghan security czar visits Pakistan to remove irritants in ties
The Afghan IS affiliate said it had carried out the attack and claimed to have killed "50 military trainees".
Police and security forces in and around Kabul have come under frequent attack in recent weeks, even as the US and the Taliban have held talks about a possible peace agreement.
Opened in 2005 and named after former vice president Mohammed Fahim, the Marshal Fahim academy is modelled after US and British war colleges and trains cadets destined to become officers in Afghanistan's army.
A large annexe to the university is home to dozens of NATO troops who mentor the Afghan cadets.
The explosion was not believed to have affected operations at that centre, which lies behind multiple layers of tight security.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ