The Taliban claimed responsibility for the attack, saying it was a warning to U.S. President Obama, who had cleared Afghan airspace less than two hours before the incident, The New York Times reported.
At least one Taliban fighter died in the ensuing fighting with Afghan special police and Norwegian military officers, The Wall Street Journal reported.
Hospital officials said 18 other people were hospitalized, including seven schoolchildren at a nearby school, and one person was in a critical condition.
Obama made an unannounced visit to Afghanistan Tuesday and met with Afghan President Hamid Karzai to sign a strategic partnership agreement.
The attack occurred at the gate of a compound known as Green Village, which houses private security guards, some foreign diplomats, U.N. employees and other foreign workers in the city, the ministry spokesman said.
Residents living near the compound and people inside said they heard several blasts, mortar explosions and gunfire, the Times said.
In a telephone interview with the Times, Taliban spokesman Zabiullah Mujahid said, "As soon as the mujahedin learned about Obama's trip to Kabul we planned to conduct an operation at the heart of the city to send a message to Obama that instead of signing strategic partnerships and instead of imposing a corrupt and unpopular government over the people of Afghanistan, he should think of ways to withdraw his troops from Afghanistan."
Witnesses said the insurgents were dressed completely in Islamic veils to conceal their weapons, the Journal said. One insurgent detonated a car bomb that destroyed the main gate and at least two insurgents entered the compound and took over a laundry and maintenance building.
Celebrity Couples of 2014 [PHOTOS]