The Taliban have announced a three-day ceasefire with Afghan government forces coinciding with Eid later this month, days after a unilateral ceasefire was ordered by the government.
It is the Taliban's first ceasefire since the government they ran was toppled by the 2001 US-led invasion.
The Taliban said it would stop all offensive operations during the holiday, except against foreign forces.
Earlier, Taliban fighters killed dozens of Afghan security force members.
Afghan President Ashraf Ghani said the Taliban move was an opportunity for the militants to realise "their violent campaign" was "not winning them hearts and minds but further alienating the Afghan people from their cause".
Government forces will not stop fighting other militants operating in Afghanistan, like the Islamic State (IS) group, during the ceasefire.
Previous offers of peace talks and ceasefires with the Taliban have come to nothing.
The Afghan government's unconditional truce followed a meeting of clerics, who earlier this week issued a fatwa condemning militant violence as un-Islamic.
The clerics were themselves targeted in a suicide attack claimed by IS, which killed 14 people outside their peace tent in Kabul this week.
The Taliban did not specify why they made the surprise decision to agree to the truce in their statement, but they said they would consider releasing prisoners of war as long they did not return to fighting against them.
However, the group warned that it would "strongly defend" itself if it came under attack.
Afghan officials hailed the Taliban's move to join the ceasefire. The UN special representative for Afghanistan, Tadamichi Yamamoto, said he hoped it would "serve as as stepping stone" towards peace talks.
When will it actually happen?
No exact date has been given. It is timed to coincide with Eid-al-Fitr, which marks the end of the holy month of Ramadan.
Afghan calendars mark the end of Ramadan as 15 June.
What about foreign forces?
In Washington, the state department said US forces and coalition partners in Afghanistan would "honour the ceasefire".
Foreign troop levels in the country have dropped to about 15,000. Last August, US President Donald Trump unveiled a more hawkish strategy in Afghanistan, including a surge of air strikes and committing more troops.
Their presence has been a major sticking point for the Taliban, who have long demanded they completely withdraw from the country as a pre-condition for peace talks to begin.
The Nato combat mission, which at one point numbered more than 130,000 troops, withdrew from Afghanistan in 2014.
What's the latest on the ground?
News of the forthcoming truce has not prevented further violent incidents across Afghanistan. On Saturday alone, more than 60 members of the Afghan security forces were killed in separate Taliban attacks:
- 23 soldiers killed and nine wounded in southern Kandahar province and another 17 killed in Herat, in the west
- 19 police officers killed in north-eastern Kunduz province
- Six killed and seven injured in northern Sar-e-Pol province
Tens of thousands of Afghans have been killed since the US-led invasion drove the Taliban from power in 2001.
How much territory do the Taliban control?
The militants have made substantial territorial gains across the country since the withdrawal of thousands of troops in 2014, with security incidents at their highest level in more than 10 years.
A BBC study from January found the Taliban are openly active in 70% of Afghanistan and now control or threaten more territory than before the foreign troops left.
The same research found that IS was also more active, but is not as powerful as the Taliban.
Who are the Taliban?
The hardline Islamic Taliban movement swept to power in Afghanistan in 1996 after the civil war which followed the Soviet-Afghan war, and was ousted by the US-led invasion five years later
In power, they imposed a brutal version of Sharia law, such as public executions and amputations, and banned women from public life.
Men had to grow beards and women to wear the all-covering burka; television, music and cinema were banned
They sheltered al-Qaeda leaders before and after being ousted. Since then they have fought a bloody insurgency which continues today.
In 2016, Afghan civilian casualties hit a new high - a rise attributed by the UN largely to the Taliban.