The United States and the Taliban are on the edge of an agreement that could end 18 years of war, Washington's special envoy to Afghanistan said on Sunday. The apparent progress comes despite another attempt by Taliban insurgents to <a href="https://www.thenational.ae/world/asia/taliban-attacks-kunduz-city-again-as-peace-talks-continue-1.904583">capture the northern Afghan city of Kunduz</a> on Saturday as negotiators held talks with the US. The strategic city was targeted from three directions, and militants took over residential homes as well as the main hospital. Special envoy Zalmay Khalilzad tweeted: "We are at the threshold of an agreement that will reduce violence and open the door for Afghans to sit together to negotiate an honourable and sustainable peace." Mr Khalilzad arrived in Kabul on Sunday to discuss developments with Afghan officials. Afghan officials said they had contained the attack on Kunduz with support from the Afghan Air Force and the US-led Nato coalition forces, with several air strikes in Pul-e-Shenwari, Qahwa Khan and other parts of the city. Security officials said at least 35 Taliban fighters had been killed in the city, including one commander, while eight civilians were killed according to public health officials, including women and children, and 59 were injured. Kunduz police spokesman Sayed Sarwar Hussainy said nine Afghan security forces were killed. Hussainy was later himself killed while briefing reporters on the fighting in a suicide bombing that severely injured a police commander, Manzour Stanekzay, who was also providing updates to the media. US General Scott Miller, commander of the coalition forces Afghanistan, visited the Kunduz along with Assadullah Khalid, acting minister of defence, and Massoud Andarabi, acting interior minister, on Saturday morning in a show of strength and government control over the city. However, sporadic firing continued around Kunduz until the early evening. On Saturday, Mr Khalilzad said in another tweet he had raised the attack with the Taliban and told them "violence like this must stop." In 2015 the Taliban overwhelmed local forces and briefly seized Kunduz, and it was only retaken by Afghan forces with US air support. Intense fighting also broke out Sunday in Pul-e Khumri, the capital of neighbouring Baghlan province, but officials said the situation was "under control". Meanwhile in the northern province of Balkh, the governor's spokesman Munir Ahmad Farhad said eight civilians were killed when their car hit a Taliban mine. US Secretary of State Mike Pompeo has previously said he hoped a peace deal would be finalised before September 1, before Afghan elections on September 28. Suhail Shaheen, the Taliban's spokesman in Doha, said on Saturday that a deal was "near to finalised" but did not specify what obstacles remain. Afghan-born Mr Khalilzad, who previously served as the US ambassador to Kabul, has spent the last year or so criss-crossing the globe in a bid to build support for a deal with the Taliban. While the agreement would not immediately assure peace, it is designed to lead to a drop in violence. The agreement will centre on the US beginning to withdraw approximately 13,000 troops in exchange for a Taliban guarantee that Afghanistan will not be used as a jihadist safe haven. Negotiations between the Taliban and the Afghan government, and an eventual ceasefire, will also be key pillars of any deal. The deal would pave the way to "a unified, sovereign Afghanistan that does not threaten the US, its allies, or any other country", Mr Khalilzad said. He did not say if he had a finalised text to show Afghan authorities, but several officials have hinted in recent days that moving talks to Kabul could signal a positive outcome. The apparent final phase of talks follows an excruciating few months for Afghans. The war-torn nation's people have watched on largely voiceless as US negotiators cut a deal with the Taliban while largely sidelining the government of President Ashraf Ghani. Fearing a return to power of the hardline Taliban, many worry the deal and subsequent negotiations will lead to a reduction in personal freedoms and limited women's rights that modern Afghans have grown accustomed to. US troops were first sent to Afghanistan after the September 11, 2001 attacks carried out by Al-Qaeda, which was sheltered by the former Taliban regime. Washington now wants to end its military involvement — the longest in its history – and has been talking to the Taliban since at least 2018. Afghanistan has also suffered a string of ISIS attacks in recent week, with 80 people from a Shiite minority killed at a wedding reception attack on August 18. Experts believe ISIS’s latest offensive in Afghanistan is an attempt to derail peace talks between the US, the Taliban and the Afghan government.