KABUL, AFGHANISTAN - Mark Esper sought a firsthand assessment Sunday of the U.S. military's future role in America's longest war as he made his initial visit to Afghanistan as Pentagon chief. Stalled peace talks with the Taliban and unrelenting attacks by the insurgent group and Islamic State militants have complicated the Trump administration's pledge to withdraw more than 5,000 American troops.

Esper told reporters traveling with him that he believes the U.S. can reduce its force in Afghanistan to 8,600 without hurting the counterterrorism fight against al-Qaida and the Islamic State group. But he said any withdrawal would happen as part of a peace agreement with the Taliban.

The U.S. has about 14,000 American troops in Afghanistan as part of the American-led coalition. U.S. forces are training and advising Afghan forces and conducting counterterrorism operations against extremists. President Donald Trump had ordered a troop withdrawal in conjunction with the peace talks that would have left about 8,600 American forces in the country.

U.S. envoy Zalmay Khalilzad had a preliminary peace deal with the Taliban, but a surge in Taliban violence and the death of an American soldier last month prompted Trump to cancel a secret Camp David meeting where the peace deal would have been finalized. He declared the tentative agreement dead.

'The aim is to still get a peace agreement at some point, that's the best way forward,'' said Esper. He visited Afghanistan in his previous job as U.S. Army secretary.

He would not say how long he believes it may be before a new peace accord could be achieved.

A month after the peace agreement collapsed, Khalilzad met with Taliban in early October in Islamabad, Pakistan, but it was not clear what progress, if any, was being made.

Esper's arrival in Kabul came as Afghan government leaders delayed the planned announcement of preliminary results of last month's presidential election. Esper met with Afghan President Ashraf Ghani and other government officials.

House Speaker Nancy Pelosi was visiting Afghanistan with a congressional delegation at the same time.

Her office said in a statement Sunday night the bipartisan delegation met with top Afghan leaders, civil society representatives and U.S. military chiefs and troops serving there. Pelosi says the delegation emphasized the importance of combating corruption and ensuring women are at the table in reconciliation talks.

Both Ghani and his current partner in the unity government, Chief Executive Abdullah Abdullah, have said they believe they had enough votes to win. The Sept. 28 vote was marred by widespread misconduct and accusations of fraud.

Officials said the announcement of preliminary results has been delayed due to problems with the transparency of the process, delays in transferring ballot papers and delays in transferring data from a biometric system into the main server.

Esper planned to meet with his top commanders in Afghanistan as the U.S. works to determine the way ahead in the 18-year war.

Trump, since his 2016 presidential campaign, has spoken of a need to withdraw U.S. troops from the "endless war'' in Afghanistan. He has complained that the U.S. has been serving as policemen in Afghanistan, and says that's not the American military's job.