Suicide bombers and gunmen have attacked an election commission office beside the home of Afghan presidential candidate Ashraf Ghani Ahmadzai and engaged in a lengthy gun battle with security forces, less than two weeks before a presidential poll.
Security forces cordoned off the area in western Kabul and besieged the building for several hours on Tuesday as the armed men returned fire from their positions.
"The operation is over," the deputy interior minister, General Ayoub Salangi, told Reuters news agency. "Five enemies were killed and all election workers trapped inside were rescued."
Two policemen, an election worker and a provincial council candidate were killed, a spokesman for the interior ministry said.
The Taliban claimed responsibility for the attack. The group has vowed a campaign of violence to disrupt the ballot on April 5, urging their fighters to attack polling staff, voters and security forces in the run-up to election day.
Ghani, a former World Bank official who is seen as a frontrunner in the race to succeed President Hamid Karzai, was not at home at the time of the attack.
Police initially said the armed men had attacked Ghani's house itself but later Ghani's campaign aide said the assault targeted an adjacent building.
"The attack was on an election office next to Dr Ashraf Ghani's house," said the aide. "His house was also hit by the attackers."
Ghani, in a Twitter post after the attack, said: "Just arrived at Gardez rally, a huge crowd of tens of thousands." Gardez is in a volatile area south of Kabul.
Later, he added: "Terrorists cannot deter us from our cause with their cowardly attacks. My family is safe.
President Hamid Karzai is barred from running for another term after 12 years in power but is widely expected to retain his influence.
Meanwhile, Afghan officials in Kunduz province in northern Afghanistan said on Tuesday that two people were killed and eight others wounded after a suicide bomber detonated his explosives.
All the casualties were members of presidential candidate Dr Abdullah Abdullah's campaign team.