WASHINGTON — Secretary of State Mike Pompeo said Tuesday that negotiations with the Taliban have produced "real progress" but that the Trump administration had not yet clinched an agreement on when American troops would leave Afghanistan, where the United States has been at war for more than 17 years.

During an unannounced visit to Kabul, Pompeo said the U.S. and the Taliban are close to an agreement on the insurgency's pledge to sever ties with Al Qaeda and other terrorist groups.

"Regarding terrorism, we've made real progress and are nearly ready to conclude a draft text outlining the Taliban commitments to join fellow Afghans in ensuring that Afghan soil never again becomes a safe haven for terrorists," Pompeo told reporters.

The two sides also have held talks on the presence of U.S. and other foreign troops, Pompeo said.

"And while we've made clear to the Taliban that we're prepared to remove our forces, I want to be clear — we've not yet agreed on a timeline to do so."

About 14,000 U.S. troops are deployed in Afghanistan and President Donald Trump has expressed impatience with the conflict and would like to withdraw those forces from the country.

Pompeo said that "the hour has come for peace" in America's longest war and said he hoped there would be a peace deal in place before Sept. 1, as Afghanistan's long-delayed presidential elections are due to be held in late September.

He said "the pursuit of peace should not wait till the Afghan presidential election" in September. "Election planning must go forward without delay as we pursue the peace that Afghans deserve."

Pompeo's remarks signaled no imminent breakthrough in the nine-month-long reconciliation talks led by Zalmay Khalilzad, an Afghan-born veteran diplomat who served as the U.S. ambassador to Kabul under the Bush administration. Khalilzad had said in March that the two sides had worked out draft agreements on the terrorism issue and on a U.S. withdrawal, and it was unclear how the discussions have evolved since then.

Pompeo's talk of a possible "peace deal" done by Sept. 1 "begs the question what they think a peace deal means," Laurel Miller, a former U.S. diplomat with experience in Afghanistan, said.

"An agreement on troop withdrawal just between the U.S. and the Taliban could be reached by then, but an actual peace agreement among Afghans by September would be nothing short of miraculous," said Miller, now Asia director at the International Crisis Group think tank.

Apart from hammering out a deal on a U.S. withdrawal and Taliban guarantees on preventing terrorism, the U.S. wants to secure an agreement with the insurgents on a cease-fire and a commitment for negotiations between the Taliban and the Western-backed Afghan government.

The Taliban have so far refused to agree to a cease-fire and to hold direct talks with the Afghan government, which they portray as a "puppet" of the U.S. The hard-line Islamist insurgents control more territory now than at any time since the U.S. military toppled the regime in 2001 over its ties to Al Qaeda.

Afghan officials and civil society leaders have expressed grave concern about the U.S. talks with the Taliban, fearing that the Trump administration could pull out American troops without safeguarding the future of the Afghan government.

Pompeo said Tuesday that the U.S. would not dictate the terms of any peace agreement. "We are not and will not negotiate with the Taliban on behalf of the government or people of Afghanistan," he said.

U.S. and Taliban representatives are due to hold their ninth round of discussions in the Qatari capital of Doha later this week.

Pompeo also said Germany and Qatar are helping to organize a gathering next month of a range of Afghan representatives and figures as well as Taliban members, in what he called a "dialogue" among Afghans. The meeting would offer an opportunity for Afghans to endorse the need for peace negotiations, he said.