Iran on Wednesday hosted the first significant talks in months between the Taliban and Afghan government representatives — a previously unannounced meeting that comes as the U.S. completes its withdrawal from Afghanistan and districts increasingly fall to the Taliban across the country.

The high-level peace talks between the warring Afghan sides follow months-old discussions in Qatar that have been stalled by a diplomatic stalemate and escalating violence. Even as officials faced each other across the vast tables in Tehran and Iran’s top diplomat pledged to end the crisis, fighting surged in Afghanistan’s western Badghis province.

The Taliban political committee, led by chief negotiator Sher Mohammad Abbas Stanikzai, flew from Doha to Iran’s capital to meet Afghan government officials, including former Vice President Younus Qanooni and others from the High Council for National Reconciliation.

Afghan soldiers pause on a road at the front line of fighting between Taliban and Security forces, in Badghis province, northwest of Afghanistan, Wednesday, July, 7 2021. 

Afghan soldiers pause on a road at the front line of fighting between Taliban and Security forces, in Badghis province, northwest of Afghanistan, Wednesday, July, 7 2021.  (AP Photo/Mirwis Omari)

US-IRAN NUCLEAR DEAL STALEMATE A ‘MISTRUST-AND-VERIFY SITUATION,’ FORMER CIA CHIEF SAYS

Iranian Foreign Minister Mohammad Javad Zarif greeted the delegates, urging them to "take difficult decisions today for the future of their country," state-run media reported.

After the "failure of the U.S. in Afghanistan," Zarif said, Iran stands "ready to assist the dialogue" and to "resolve the current conflicts in the country."

"Returning to the inter-Afghan negotiation table and committing to political solutions is the best choice," he added. Later, Zarif tweeted the meeting had been "cordial" and promised Iran would stand with Afghans on their road to peace.

But any solution appeared a long way off Wednesday as the Taliban offensive, which has recently captured many districts in the country’s north, pushed into Badghis province. The insurgents attacked the provincial capital of Qala-e-Naw from several sides, its governor Hasamuddin Shams said, adding that Afghan troops had so far managed to push the Taliban back.

From early Wednesday morning, battles raged near the provincial police headquarters and a Qala-e-Naw army base, said Abdul Aziz beg, head of the provincial council in Badghis.

The fighting killed at least two civilians and wounded 28 others, including women and children, said Dr. Sanahullah Sabit at the Provincial Badghis Hospital. Medics sent five people in critical condition to a regional hospital in the neighboring Herat province for further treatment, he added.

Videos widely circulated on social media appeared to show Taliban fighters speeding into the provincial capital on motorcycles. Other clips show insurgents approaching the city’s prison and releasing inmates. The Associated Press could not independently verify the authenticity of the footage.

Fawad Aman, the Afghan defense minister’s deputy spokesman, promised security forces would clear the city in the coming hours. The Taliban have not publicly commented on the violence in Qala-e-Naw.

The surge in fighting — and the sudden news of peace talks in Tehran — come at a critical time for the war-battered country.

After a two-decade-long military campaign, the U.S. military announced on Tuesday that 90% of American troops and equipment had already left the country, with the drawdown set to finish by late August. Last week, U.S. officials definitively vacated the country’s biggest airfield, Bagram Air Base, the epicenter of the war to oust the Taliban and hunt down the al-Qaida perpetrators of the 9/11 terrorist attacks on America.

An Afghan civilian carry a wounded child to the hospital after he was injured during fighting between Taliban and government in Badghis province, northwest of Afghanistan, Wednesday, July, 7 2021.

An Afghan civilian carry a wounded child to the hospital after he was injured during fighting between Taliban and government in Badghis province, northwest of Afghanistan, Wednesday, July, 7 2021. (AP Photo/ Mirwis Omari)

The Taliban have made relentless territorial wins since April, when President Joe Biden announced that the last 2,500-3,500 U.S. soldiers and 7,000 allied NATO soldiers would depart Afghanistan. With their victories in northern and southern Afghanistan, the Taliban are escalating pressure on provincial cities and gaining control of key transportation routes.

Afghanistan’s uncertain path toward peace bears profound consequences for its western neighbor Iran, which the U.N. estimates hosts some 2 million undocumented Afghans. Amid the specter of another civil war, fears have grown in Iran over a new wave of Afghans seeking refuge in the country, which already is struggling to stem worsening poverty under tough U.S. sanctions.

CLICK HERE TO GET THE FOX NEWS APP

Iran and Afghanistan share deep cultural ties and a 945-kilometer-long (587 miles) border. Tehran has historically viewed U.S. military presence in neighboring countries as a threat and pushed for American troop withdrawals from the region.

Iran, the Shiite powerhouse of the Middle East, has occasionally in the past hosted the Sunni militant Taliban and Afghan government officials in Tehran for peace talks. In playing host, Iran seeks counterbalance against regional rivals like Saudi Arabia that typically wield greater influence over Sunni groups in the Middle East.

The Taliban’s recent territorial gains also have fueled national security concerns in Iran.

"We do warn the Taliban not to get close to Iranian borders," said lawmaker Shahriar Heidari, a member of influential parliamentary committee on national security and foreign relations. "This is Iran’s red line."