The Trump administration is nearing an agreement with the Taliban that would end America's longest war, the U.S. envoy said Saturday.

But as Zalmay Khalilzad flew into Kabul to brief the Afghan government on a peace deal, the insurgent group launched an attack on a second Afghan city in as many days.

The assault on the capital of Baghlan province Sunday came hours after Khalilzad said he warned the Taliban during talks in Qatar that "violence like this must stop."

But he appeared determined to move forward on a deal that plans the withdrawal of U.S. troops in exchange for Taliban guarantees that Afghanistan will not be used as a launch pad for global attacks.

"We are at the threshold of an agreement that will reduce violence and open the door for Afghans to sit together to negotiate an honorable and sustainable peace and a unified, sovereign Afghanistan that does not threaten the United States, its allies, or any other country," he said in a Twitter post.

After completing the latest round of talks in Doha, Khalilzad traveled to Kabul to consult with a "wide range of Afghans, including the government leadership," a state department spokesperson said.

"Despite speculation, we do not yet have an announcement to make," the spokesperson added.

"However, we can tell you that any potential peace deal will not be based on blind trust, but will instead contain clear commitments that are subject to our monitoring and verification. Any potential deal would bring together all sides for negotiation, enable the withdrawal of American forces, and ensure the security of the American homeland."

The latest assault came a day after the Taliban attacked Kunduz, one of Afghanistan's largest cities, in the province to the north and killed at least 16 people and wounded nearly 100. The interior ministry on Sunday said the Taliban had been cleared from that city but some fighters had fled to Baghlan.

The attacks are seen as strengthening the negotiating position of the Taliban, who control or hold sway over roughly half of Afghanistan and are at their strongest since their 2001 defeat by a U.S.-led invasion.

President Donald Trump has made clear he wants to end the U.S. troop presence in Afghanistan, and Secretary of State Mike Pompeo on Monday said he had orders to scale back American forces by the 2020 election.

Some 20,000 U.S. and NATO forces are stationed in Afghanistan training and supporting Afghan forces fighting the Taliban and a local affiliate of the Islamic State group.