The attack came as a major blow to NATO's efforts to train up the Afghan military before foreign forces end their combat mission in December after 13 years of fighting the Taliban.
The New York Times and NBC news, citing unnamed sources, said a US major general had been shot dead in what would be the highest-level fatality of the war.
Among the injured in the attack at the Marshal Fahim National Defense University were 15 US troops, three Afghan soldiers and a German brigadier general, officials said.
"A terrorist wearing Afghan army uniform opened fire at national army officers and their foreign colleagues and wounded several people," defence ministry spokesman Mohammad Zahir Azimi said on Twitter.
Also Read
The British-run Afghan National Army Officer Academy is part of the university, but the NATO's International Security Assistance Force clarified an earlier statement that said the attack was inside the academy.
"ISAF confirms that an incident occurred today involving local Afghan and ISAF troops at the Marshal Fahim National Defense University," the force said. "ISAF can confirm one ISAF service member was killed."
President Hamid Karzai condemned the attack as a "cowardly" strike against Afghan and NATO officers who were visiting the military training university on the outskirts of the capital.
"It is the work of those enemies who do not want to see Afghanistan have its own strong institutions," he said.
General Mohammed Afzal Aman, the chief of staff for operations at the Afghan Ministry of Defence, told AFP that three Afghan army officers were injured.
"ISAF have quarantined the site, allowing nobody, including Afghan forces, to approach," he said.
The Afghan military has been built from scratch since the fall of the Taliban regime in 2001, and it has struggled with high casualty rates, "insider attack" killings, mass desertions and equipment shortages.