Four insurgent gunmen launched a pre-dawn attack on India's consulate in the western Afghan city of Herat on Friday before being repelled by security forces, in an assault highlighting instability as NATO troops withdraw. There were no casualties among Indian staff but at least one policeman was wounded when the attackers stormed a house close to the consulate and opened fire on the building. Afghanistan is in the middle of elections to choose a successor to President Hamid Karzai, who has ruled since the fall of the 1996-2001 Taliban regime. Pakistan was the Taliban's main ally and the Pakistani security forces have often been accused of assisting the insurgents, especially with attacks on Indian targets in Afghanistan. "Four Taliban attackers entered a residential house behind the consulate in the early morning," Mohammad Yousuf Pashtoon, commander of Herat's paramilitary Quick Reaction Force, told AFP. "Security forces evacuated residents from the building and fought to clear the building." The interior ministry said all the insurgents had been killed but sporadic gunfire continued at the scene. India has been a key supporter of Kabul's post-Taliban government, and analysts have often pointed to the threat of a "proxy war" in Afghanistan between India and its arch-rival Pakistan. The Pakistani government issued a swift condemnation of the attack, saying it was opposed to "terrorism in all its forms and manifestations". The Taliban did not immediately claim responsibility for the attack, which came after incoming prime minister Narendra Modi invited Pakistan premier Nawaz Sharif to his inauguration in Delhi next week. "One gunman was shot by the ITBP (Indo-Tibetan Border Police) while they were trying to breach the consulate," Indian foreign ministry spokesman Syed Akbaruddin told the news channel NDTV. He added that Indian and Afghan security forces had been "successful in rebutting this attack". - Bitter regional rivalries - Afghanistan has seen a flare-up in violence ahead of the second-round run-off presidential election on June 14, with 16 policemen killed in a series of attacks in the space of 24 hours earlier this week. Providing security for the election is a key test for Afghan police and soldiers, with all NATO combat troops due to pull out of the country by December after more than a decade fighting the Taliban. Friday's assault against the consulate in Herat is the latest in a long line of attacks against Indian targets in Afghanistan. Nine civilians, including seven children, were killed in August last year when suicide bombers targeted the Indian consulate in the eastern city of Jalalabad, detonating an explosives-packed car. 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. And in 2010, two guesthouses in Kabul used by Indians were attacked. Sharif is still mulling whether to take up the invitation to attend Modi's swearing-in ceremony, with many hoping it would help ease tensions between the nuclear-armed neighbours. Pakistan denies supporting militants active in Afghanistan and points to its own bloody fight against Islamist extremists. India has poured $2 billion in reconstruction aid into Afghanistan and has been asked for further support, including military assistance in Kabul's battle to contain the Taliban insurgency. While the government in New Delhi is wary of being sucked into the unrest, it has pledged to do all it can to help promote stability in Afghanistan. Afghanistan's outgoing President Hamid Karzai has particularly good relations with New Delhi and obtained a Masters degree in politics when he was a student in India.