Image copyright Getty Images Image caption Afghan forces have been trying to clear the building near the Indian mission

Afghan forces have been battling militants to flush them out from a building near the Indian consulate in the northern city of Mazar-e-Sharif.

Explosions and gunfire have been heard near the building on Monday.

Officials said the attackers had unsuccessfully tried to enter the consulate compound and were now in an adjacent building. Security forces have cordoned off the area.

Indian missions have come under attack in the past in Afghanistan.

Indian ambassador to Afghanistan, Amar Sinha, told the Press Trust of India news agency that all consulate staff were safe and a clearing operation was under way.

Afghan officials said they were "proceeding very cautiously to avoid civilian casualties".

"Our clearance operation is going on near the consulate," Munir Farhad, a spokesman for the Balkh provincial governor, told the AFP news agency.

Police officials in Mazar-e-Sharif said the gunmen were armed with RPGs (rocket propelled grenades), hand grenades and light weapons.

Provincial police spokesman Sher Jan Durani told the AP news agency that the armed men were shooting at the Afghan forces from inside the building.

No group said it was behind the attack.

In 2008 and 2009, the embassy in Kabul was attacked twice, with dozens killed.

In May 2014, heavily-armed gunmen attacked the Indian consulate in Herat, while in August 2013 nine civilians died when the consulate in Jalalabad was targeted.

The recent attack in Mazar-e-Sharif comes after Indian Prime Minister Narendra Modi's visit to Kabul last month.