Afghanistan's government and the Taliban should hold direct talks, the UN urged on Tuesday, saying a stalled American-led peace process had opened the door to ending the war.
The call came a day after US President Donald Trump said negotiations with the insurgents were “dead, as far as I am concerned”.
The Taliban responded by pledging that fighting would replace talks if the US military attacked their fighters.
Afghanistan has elections planned for September 28.
Seeking to regain the initiative, the UN Secretary General's special representative for Afghanistan, Tadamichi Yamamoto, said direct negotiations were the only way forward and it was imperative that they commence as soon as possible.
“Often, the period just before coming to an agreement is the most difficult phase," Mr Yamamoto said.
"I call on the parties to continue to seize the opportunity of direct talks so that a peaceful future can be built.”
Mr Trump at the weekend cancelled a secret summit that would have brought Taliban officials, Afghan President Ashraf Ghani and the US government to Camp David, near Washington.
The proposed meeting in the US would have followed nine rounds of talks between the US and Taliban representatives in Qatar's capital, Doha.
Leaving Afghanistan, where US troops have fought against the Taliban since 2001, remains a top priority for Mr Trump before his 2020 re-election bid.
The US president repeated on Monday that he wanted "to get out by the earliest possible time".
But he scrapped the planned talks after last week's killing of an American soldier and civilians in a bomb attack by the Taliban, and signalled a shift back towards a military campaign.
“Over the last four days, we have been hitting our enemy harder than at any time in the last 10 years," Mr Trump wrote in a tweet on Monday.
It is understood that the US was prepared to withdraw 5,400 troops over the next five months, in return for a guarantee from the Taliban that Afghanistan would never again be used as a base for terrorism as it was before the September 11, 2001 attacks.
UN diplomats said the failed US effort, which was criticised for excluding Afghanistan's government, showed the need for direct talks, despite the Taliban's repeated pledges to disrupt the elections.
“We need a political agreement,” said Belgium's ambassador to the UN, Marc Pecsteen de Buytswerve.
“You cannot sign a political agreement with one hand and throw a bomb with the other hand. Clearly, there is a problem.”