US Defence Secretary Mark Esper has arrived in Afghanistan where stalled peace talks with the Taliban and persistent attacks by armed groups have complicated the Trump administration’s pledge to withdraw more than 5,000 American troops.

Esper told reporters travelling with him that he believed the US could reduce its force in Afghanistan to 8,600 without hurting the counterterrorism fight against Al-Qaeda and the Islamic State of Iraq and the Levant (ISIL, ISIS) group.

But he said any withdrawal would happen as part of a peace agreement with the Taliban.

The US has about 14,000 American troops in Afghanistan as part of the US-led coalition. US forces are training and advising Afghan forces and conducting counterterrorism operations.

President Donald Trump ordered a troop withdrawal in conjunction with the peace talks that would have left about 8,600 American forces in the country.

US envoy Zalmay Khalilzad brokered 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 agreement would have been finalised. 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, who was making his first trip to Afghanistan as defence secretary. He would not say how long he believed it might be before a new peace accord could be achieved.

In early October, a month after the peace agreement collapsed, Khalilzad met with the Taliban in Islamabad, 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 said he planned to meet with Afghan President Ashraf Ghani. Both Ghani and his current partner in the unity government, Chief Executive Abdullah Abdullah, have said they believe they had enough votes to win.

Esper also plans to meet with his top commanders in Afghanistan as the US works to determine the way ahead in the 18-year war.

Meanwhile on Sunday, the European Union called for a ceasefire, saying the breakdown in talks between the US and the Taliban presented an opportunity to push anew for a truce.

“It’s the right moment and the right opportunity to maybe go one step beyond a simple reduction in violence and explore ways in which a ceasefire ... will take place,” Roland Kobia, EU special envoy to Afghanistan, told journalists in Kabul.

“The idea is really to see how we can move the ceasefire idea forward instead of leaving it for later. ... There is an opportunity here today.” Kobia added.

When asked how the EU, which has only a limited footprint in Afghanistan, could leverage a ceasefire, Kobia suggested that the Taliban might return to power in “one form or another” within months so would entertain a truce to help normalise future relations with the European bloc. “A ceasefire would be a token, a guarantee of goodwill and good preparation for the normalisation of these relationships,” Kobia said.

The Taliban, for its part, have steadfastly ruled out an immediate ceasefire but last year downed weapons for a three-day truce.

Afghanistan is currently in an uneasy waiting period following the first round of presidential elections on Sept 28. Results were supposed to be released Saturday but have been indefinitely delayed due to “technical issues”, the Independent Election Commission said.

Pierre Mayaudon, head of the EU delegation in Afghanistan, said a delay of a few days to finalise results was legitimate to ensure votes were fairly counted.

“But not many more days that again will go into weeks and will possibly raise the perception that something is happening,” he told reporters.

Violence in Afghanistan meanwhile continues unabated. On Friday, at least 70 people were killed when a mosque in Nangarhar province was bombed.