Tehran has dismissed accusations that it has been helping a Taliban push in an Afghan province bordering Iran, saying the claim is instigated by US commanders who try to divert public opinion from the real cause of the flare-up in violence.

Fighting has continued in Farah Province on the border with Iran where the insurgents came close to overrunning the provincial capital, prompting its police chief to echo US claims that Iran was supporting the Taliban.

“The Taliban's attack on Afghan cities and their recapture by government forces is not a new thing and is not related to good relations between the two neighboring countries,” Foreign Ministry spokesman Bahram Qassemi said in Tehran Monday.

Taliban fighters with heavy weapons and night-vision equipment fought their way close to the center of the western city of Farah last week.

Local residents had for months warned that the city was vulnerable and the attack threatened a repeat of the Taliban’s capture of the northern city of Kunduz in 2015.

Taliban fighters on Sunday closed in on another district in the Afghan Province of Ghazni, which is far from the Iranian border.

On Saturday, top US commander in Afghanistan General John Nicholson visited Farah. Local officials complain about the failure to protect the city and the province, where the Taliban control many areas.

Qassemi said, “US commanders who have been unable to establish security in Afghanistan after years of massive military presence and shedding the blood of thousands of innocent people are trying to deflect the public opinion of Afghanistan from the real reasons behind the perpetuation of the war by accusing the Islamic Republic of supporting the Taliban.”

“The Islamic Republic of Iran has been standing for nearly four decades alongside the friendly and brotherly government and people of Afghanistan to defend their sovereignty and independence, and the statements made to satisfy outsiders and invaders have no congruity with these friendly relations,” he added.

Some Afghan officials have charged that Iran was ratcheting up its support for the Taliban to disrupt development projects in Afghanistan, including dams which could reduce water flow to Iran.

Afghanistan has unveiled plans to construct 20 new dams, with Herat, Farah and Helmand being the three provinces where a significant number of rivers that flow toward Pakistan and Iran are sourced.

Iran and Afghanistan have been embroiled in water disputes for years, but Qassemi stressed that both countries continue to use “diplomatic channels” to resolve them.

“Linking this issue with Afghanistan's internal affairs does not have any rational, correct and reasonable basis,” he said.

The spokesman also called on warring sides in Afghanistan to resolve their problems through peaceful means.

“Like in the past, while supporting the peace process led by the Afghan government, we invite the parties to the conflict to try to solve the problems through negotiation,” Qassemi said.