All three militants were killed in an attack on a base of the Afghan intelligence agency in former Taliban stronghold of southern Kandahar province on Wednesday, police said.
"Our security personnel killed all attackers who attempted to overrun the compound of the National Directorate for Security (NDS) ," deputy provincial police chief Rahmatullah Atrafi said.
"All three terrorists were killed and two security personnel injured in the clash which lasted for about an hour," Atrafi added.
Earlier provincial police spokesman Zia Durani told Xinhua that three militants wearing suicide bomb vests launched attack on the NDS compound at around 10:00 a.m. local time in the provincial capital of Kandahar city which triggered a gun battle, but they were killed before reaching the target.
Several shops and houses nearby were damaged due to the clash, according to the eyewitnesses.
NDS said in a statement that the security personnel also seized an explosive-laden motorbike, three rifles of AK-47 and five hand grenades.
Meanwhile, Qari Yusuf Ahmadi who claimed to speak for the Taliban claimed responsibility for the attack, insisting several security personnel had been killed.
Taliban militants who have intensified offensive vowed in a statement on Monday to disrupt the presidential and provincial councils elections next month.