The Taliban have announced a ceasefire with the Afghan government that will take effect when the Muslim festival of Eid al-Fitr begins on Sunday.
It follows a rise in attacks by the hardline Islamist group against government troops in recent weeks.
President Ashraf Ghani welcomed the announcement, and said his soldiers would respect the terms of the truce.
The three-day ceasefire is likely to raise hopes of a longer-term reduction in violence in the country.
But a similar ceasefire was announced for the same festival in 2018 and was not extended.
"Do not carry out any offensive operations against the enemy anywhere. If any action is taken against you by the enemy, defend yourself," Taliban spokesman Zabihullah Mujahid said on Saturday.
He added that the ceasefire had been declared solely for Eid al-Fitr, which marks the end of the holy month of Ramadan.
President Ghani welcomed the announcement and said he had instructed the military to comply.
In a televised address from the presidential palace after Eid prayers, he said: "As a responsible government, we also want to take another step forward.
"I announce that the release of the Taliban prisoners will be accelerated and serious measures will be taken."
A prisoner exchange was agreed under a US-Taliban deal signed in February, but has become a significant hurdle during peace talks. It was meant to be a step towards ending the war, but the Taliban say Afghan officials are trying to delay the release, while officials have complained the militants' demands are unreasonable.
Could short truce revive cautious hope?
By Secunder Kermani, BBC Afghanistan correspondent
It is only the third time that the Taliban have declared a temporary truce since the conflict began.
The first was in 2018, again during Eid celebrations, and was a key moment in galvanising the peace process. Taliban fighters and members of the security forces hugged and posed for selfies together. That will not happen this time - the Taliban have ordered their members not to enter government territory.
Earlier this year, the group signed an agreement with the US setting out a timetable for the withdrawal of foreign forces from the country. But while they have stopped attacks against international troops they have continued targeting Afghan security forces.
Direct negotiations between the two sides were due to begin in March but have been delayed by a dispute over the exchange of prisoners and increased fighting. This brief reprieve in violence could help build momentum for those talks to finally start, and will revive some of the cautious hope Afghans had begun to feel: that an end to the conflict might eventually be possible.
What's the bigger picture?
Afghans and international observers had hoped for a reduction in violence between the two sides following the signing of a troop withdrawal agreement between the Taliban and the US in February.
But further talks have stalled over a prisoner swap, and attacks on government forces have escalated in recent weeks.
An attack on a maternity ward in the capital, Kabul, earlier this month prompted widespread condemnation. While the Taliban denied involvement, it prompted President Ghani to order the resumption of offensive operations against them as well as other groups.
He accused the militants of ignoring repeated calls for a reduction in violence.
Last month, the Taliban rejected a government call for a ceasefire across Afghanistan for Ramadan. They said it was "not rational" and ramped up attacks on Afghan forces.
Earlier this month, Afghan President Ashraf Ghani and his rival Abdullah Abdullah signed a power-sharing deal, ending months of political uncertainty.
What is in the US-Taliban deal?
The agreement signed by the US and the Taliban aims to bring peace to Afghanistan, ending 18 years of war since US-led forces ousted the Islamist group from power.
Under the agreement, US President Donald Trump announced 5,000 US troops would leave the country by May and he would meet leaders of the Taliban in the near future. US and Nato troops will withdraw from the country within 14 months, as long as the Taliban uphold their side of the deal.
The US also agreed to lift sanctions against the Taliban and work with the UN to lift its separate sanctions against the group. In return, the Taliban said they would not allow al-Qaeda or any other extremist group to operate in the areas they control.
But US officials also agreed to the prisoner swap as a first step in talks between the Afghan government and the Taliban - who are still technically at war. The Afghan government was not included in the talks.
The two sides held historic face-to-face talks in early April, but the Taliban walked out of the discussions.
The Afghan government says the militants' demands are unreasonable. One member of the administration's negotiating team said the Taliban were seeking the release of 15 commanders believed to have been involved in major attacks.
But the Taliban's spokesman has accused the government of delaying the release "under one pretext or another".