The US envoy to Kabul, Zalmay Khalilzad, said on Monday that the first 5,000 American troops would leave Afghanistan within five months under a deal with the Taliban. The deal was reached in principle but still needs US President Donald Trump's approval. Mr Khalilzad on Monday met Afghan leaders to show them the draft of the agreement, which included a ceasefire, to bring the 18-year conflict to an end. He earlier said the parties were "at the threshold" of a peace deal after the ninth round of talks with the Taliban ended in Qatar. The militants attacked the capitals of Kunduz and Baghlan provinces in the north over the weekend. Mr Khalilzad's discussions with the country's leaders are significant because the Afghan government has been largely sidelined from talks until now. The deal would require the Taliban to commit to power-sharing talks with Mr Ghani, who they regard as a US puppet, and work towards a ceasefire. The president will consider the draft and share his views with Mr Khalilzad within two days. The US wants to stop Afghanistan becoming a centre for terrorism and a launchpad for attacks around the world. But there are fears in the Afghan government and among the US national security establishment that any US withdrawal could leave Afghanistan vulnerable to civil unrest and a Taliban takeover. The group already controls about half of the country. Afghanistan was the deadliest conflict in the world last year. The deal with the Taliban "will reduce violence and open the door for Afghans to sit together to negotiate an honourable and sustainable peace", Mr Khalilzad, who was born in the country, said before his arrival in Kabul. His comments came after the Taliban launched operations to seize Kunduz in northern Afghanistan and an offensive on the city of Pul-e Kumri, the capital of Baghlan province. Afghan officials on Monday said that Pul-e Khumri had been cleared of Taliban fighters. US Secretary of State Mike Pompeo has said that he hopes a peace deal will be finalised before September 1, ahead of Afghan polls due on September 28. Suhail Shaheen, the Taliban's spokesman, said on Saturday that a deal was "near to finalised". The US invaded in 2001 and removed its Taliban leaders after they refused to hand over members of Al Qaeda who were behind the September 11 attack on the World Trade Centre and the Pentagon. Mr Trump has long called for an end to US involvement in Afghanistan, writing on Twitter seven years ago that the war was "a complete waste". Last week, he told Fox News that the US planned to reduce its troop presence to 8,600 and “make a determination from there”. The president has been trying to withdraw troops before next year's US election. The US has about 14,000 troops in Afghanistan, who help to train the country's forces to deal with the counter-terror threat. But it also conducts air strikes in support of the Afghan army. The group is believed to have stepped up its activity to strengthen its negotiating position with the US.