MAZAR-I-SHARIF, Afghanistan — Gunfire and explosions rocked the area around the Indian consulate in the northern Afghan city of Mazar-i-Sharif on Sunday night as security forces battled gunmen who tried to enter the compound, officials said.

Two loud blasts and shots were heard earlier as the gunmen launched an attack from a nearby house after darkness fell, Muneer Ahmad Farhad, a spokesman for the Balkh province governor said.

They were repelled after an attempt to enter the consulate and took refuge in a house across the street, he said.

“Right now our security forces are fighting them,” he said.

At least one civilian was wounded, nut no details were immediately available on any other casualties or damage, or on the number of attackers involved. There was no immediate claim of responsibility.

All members of the consulate staff were safe, according to a tweet from Indian ambassador Amar Sinha.

With heavy rain coming down and bursts of firing heard from time to time in the darkness, special forces units prepared an operation to clear the attackers out, police spokesman Shir Jan Durani said.

The incident occurred while Indian security forces were still trying to suppress an attack on an air base in Pathankot, near the border with Pakistan, that has killed at least seven military personnel and wounded 20 others.

Despite the attempt by the gunmen to enter the consulate, an Indian official said it was not absolutely certain that the consulate itself was the target. “Details are very sketchy at this point in time,” he said.

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.

Sunday’s attack came amid renewed efforts to reduce longstanding tensions between New Delhi and Islamabad and restart peace talks with the Afghan Taliban as part of a broader drive to improve stability in the region.

Last month Indian Prime Minister Narendra Modi visited both Kabul, where he inaugurated an Indian-financed parliament building and Islamabad, where he was the first Indian premier in over a decade to visit.

The attack took place shortly after India beat Afghanistan in the final of a regional soccer championship, a game that attracted wide interest in Afghanistan.