The facility was being searched for other possible attackers after the shootings Monday.
Gen. Zahir Azimi of the Defense Ministry said the two soldiers were killed when the would-be bomber opened fire inside the compound, The Washington Post said. At least seven people were wounded.
Azimi said no hostages had been taken, contrary to earlier reports.
A Taliban spokesman said several suicide bombers entered the compound and one attacker detonated his vest, The New York Times said. The spokesman said the target was a French defense official who was meeting with Afghan officials.
French officials said Defense Minster Gerard Longuet, in Afghanistan to meet with French troops deployed to the country, was not at the ministry when the attack occurred, the Times said.
A senior U.S. military official said five international coalition soldiers who died in a suicide bombing during the weekend at a military base in eastern Afghanistan were members of the U.S. Army's 101st Airborne Division, CNN reported. Four Afghan Army troops were killed and eight people were wounded.
Millions of Getty images now available for free via embed tool
NBC reportedly holds celebs hostage to Jimmy Fallon's show