An Afghan policeman talks with residents of the Ghori village in the Adraskan district of the Herat province April 3, 2014. India’s Prime Minister Narendra Modi says his country has secured the release of a Roman Catholic priest who had been taken captive by the Taliban in the same province last June. Reuters/Omar Sobhani

Update as of 4:02 a.m. EDT: All four gunmen involved in the attack on the Indian consulate in Herat, Afghanistan, on Friday, have been killed by security officials and the consulate staff members are safe, media reports said, citing officials.

India’s external affairs minister, Syed Akbaruddin, told IANS, a local news agency: “All the staff of the Indian consulate are safe,” adding: “The attempt was thwarted by the staff of the (ITBP) Indo-Tibetan Border Police, who were joined by the Afghan security forces.”

The attack, which comes before Afghan President Hamid Karzai’s visit to India on May 26, was condemned by various leaders. India's Prime Minister-designate Narendra Modi also reportedly spoke to the Indian ambassador to Afghanistan, Amar Sinha, and said in a tweet: “I condemn the attack on our consulate in Herat, Afghanistan. Closely monitoring the situation. I have spoken to the Ambassador as well.”

The Indian consulate in the western Afghan city of Herat was attacked Friday by four heavily armed gunmen suspected to belong to the militant group Taliban.

The attack reportedly began at 3:25 a.m. local time (6:55 p.m. EDT on Thursday) when the gunmen opened fire on the consulate from a nearby house using rocket-propelled grenades and machine guns. Security officials from Afghanistan and the Indo-Tibetan Border Police reportedly killed two gunmen out of the three, Associated Press, or AP, reported and evacuated nearby residents.

“Earlier this morning the consulate was attacked. Our brave ITBP personnel and Afghan soldiers were successful in rebutting the attack. All Indian personnel are safe,” Syed Akbaruddin, spokesperson for India's foreign ministry, told NDTV, a local news network, adding that senior officials from Afghanistan were monitoring the situation.

Although no group has claimed responsibility for the attack so far, Herat police chief General Samihullah Qatra told Reuters: "Four Taliban have entered residential houses close to the consulate, shooting towards the Indian consulate compound," adding: "Police have already evacuated civilians from houses and now fighting is ongoing.”

The details of the attack and the number of gunmen involved is not clear with Reuters reporting that one out of the four attackers was killed, while AP reported three gunmen had attacked the consulate and two of them had been killed. According to various news reports, a gun battle between the attackers and police personnel is continuing.

Herat, which lies near Afghanistan's border with Iran, is considered to be one of the safer cities in the strife-torn country because of a strong Iranian influence. However, the latest attack comes just before Afghan President Hamid Karzai's scheduled visit to India on May 26 to attend the swearing-in ceremony of India’s Prime Minister-designate Narendra Modi, who leads the right-wing Hindu nationalist Bharatiya Janata Party.

Afghanistan is expected to hold a second round of elections, which the Taliban has threatened to derail, on June 14 when Abdullah Abdullah and Ashraf Ghani Ahmadzai, the two candidates who received the maximum votes in the first round of polling held on April 5, will contest the presidency.