Afghan special forces killed a group of insurgents holed up in a house in the northern city of Mazar-i-Sharif late on Monday, bringing to an end a 24-hour siege following the insurgents' attack on the nearby Indian consulate.
The soldiers killed the three insurgents who had shut themselves into a large house near the consulate, said Abdul Razaq Qaderi, deputy police chief of Balkh province.
He said an investigation was under way to try to identify the men and those behind the attack, which occurred on the same day gunmen attacked an Indian air base in Pathankot in the northwestern state of Punjab near the border with Pakistan.
Eight members of the security forces were wounded in the gun battle which followed the attack on the consulate. The Indian ambassador said all the consulate staff were safe.
The attack began late on Sunday after gunmen tried unsuccessfully to break into the consulate, taking advantage of the fact that many people were watching the final of a football championship between Afghanistan and India.
After a heavy exchange of fire that went on until well into the night, security forces suspended operations before resuming in the morning, firing rocket-propelled grenades and heavy machine guns at the building.
"The area is sealed off and we are proceeding cautiously and making all possible efforts to protect the lives of those in the area. The attackers will be killed," the provincial governor, Atta Mohammad Noor, said on his Facebook page.
Gunfire rang out as helicopters circled overhead in a residential area of the city.
Noor blamed "enemies of peace and stability" for the attack, which came amid renewed efforts to lower tension between India and its rival Pakistan and restart peace talks with the Taliban in Afghanistan.
But there was no more concrete indication of who may have been responsible.
Last month, Indian Prime Minister Narendra Modi visited Kabul and Islamabad on the same day, underlining the drive to improve stability and overcome the longstanding hostility in the region.
However, Sunday's attack and the assault in Pathankot underlined how difficult that process is likely to be.
In 2014, India's consulate in the western Afghan city of Herat was hit by heavily armed insurgents including suicide bombers, one of a series of attacks on Indian diplomatic stations in Afghanistan over previous years.
Pakistan has long been suspicious of India's engagement with Afghanistan and its diplomatic presence there.
In Kabul, two suicide attacks on the same day highlighted how fragile the security situation in the country has become.