The attackers "dressed as women, wearing wigs and burqas, walked towards the guards at the NDS gates, pretending to submit an application paper", the statement said.
Officials said the men were shot dead before reaching their targets.
Zabiullah Mujahid, a Taliban spokesman, told The Associated Press news agency that as many as 15 fighters in suicide vests had staged the assault in Gardez.
US and Nato-led forces were sent to the scene to help the Afghan military and police regain control, Captain Elizabeth Mathias, a US military spokeswoman, said.
'Symbols of power'
In Jalalabad in Nangarhar province, Mohamamd Ayub Salangi, the provincial police chief, said two suicide attackers on a motorbike carrying AK-47s and a rocket propelled grenade died in an attempted attack on the city's airport, a military base.
A police officer was also killed, a local doctor said.
Mujahid said that his Taliban fighters had managed to enter the base and killed "several Afghan and foreign forces".
Al Jazeera's Zeina Khodr, reporting from the capital, Kabul, said: "They are striking at symbols of Afghan power."
"This resembles other assaults that the Taliban has carried out in recent months, less than two months ago in Khost in the southeast, they laid siege to the city for almost 10 hours."
Khost, which is 70km east of Gardez, is a key area of operations for fighters associated with a network run by Sirajuddin Haqqani, a pro-Taliban leader.
There has been a surge in violence across Afghanistan since US Marines and British forces launched two major offensives aimed at securing areas of southern Helmand province.
A British soldier was killed while on patrol in Helmand on Monday, taking the total of British dead since the 2001 invasion to 187 troops.
Britain has increased its troop levels in Afghanistan to about 9,000 soldiers this year in an attempt to improve security before a presidential election on August 20.
"Elections are less than a month away, how will they be able to protect 28,000 polling stations across the country?" Khodr asked.
"Even the Afghan election commission says that 30 per cent of those polling stations may not be secure. Interior ministry figures say that 124 out of the 364 districts are deemed unsafe."