Afghan special forces killed a group of attackers inside in a house in the northern city of Mazar-i-Sharif, bringing to an end a 24-hour siege following the attack on the nearby Indian consulate.
The soldiers killed the three attackers who had shut themselves in 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 armed men attacked an Indian air base in Pathankot in Punjab state near the border with Pakistan.
Eight members of the security forces were wounded in the Mazar-i-Sharif gun battle which followed the attack on the consulate.
The Indian ambassador said all the consulate staff were safe.
Atta Mohammad Noor, Balkh's governor, blamed "enemies of peace and stability" for the incident.
The twin attacks in Mazar-i-Sharif and Pathankot came amid renewed efforts to lower tension between India and Pakistan, and restart peace talks with the Taliban in Afghanistan.
Last month, Narendra Modi, Indian prime minister, visited Kabul and Islamabad on the same day, underlining the drive to improve stability and overcome the longstanding hostility in the region.
Sunday's attack was not the first time an Indian diplomatic post had been attacked in Afghanistan.
In 2008, a car bomb at the Indian embassy in Kabul killed 60 people and the embassy was again hit by a suicide strike in 2009.
Nine civilians, including seven children, were killed in August 2013 when suicide bombers targeted the Indian consulate in Jalalabad.
In May 2014, armed men launched a pre-dawn attack on India's consulate in the western city of Herat.