The Taliban announced Saturday a three-day ceasefire with Afghan security forces for Eid, the holiday that caps off Ramadan, though it said operations against "foreign occupiers" would continue.
But the group warned its fighters would "strongly defend" themselves if attacked, according to a statement sent to the media two days after the Afghan government made its own surprise announcement of a week-long ceasefire with the militants.
It was the first time the Taliban had agreed to a ceasefire for Eid since the US invasion in 2001.
"All the mujahideen are directed to stop offensive operations against Afghan forces for the first three days of Eid-al-Fitr," the Taliban said in a WhatsApp message.
"But if the mujahideen are attacked we will strongly defend (ourselves)."
The Taliban added that "foreign occupiers are the exception" to the order sent to its fighters.
"Our operations will continue against them, we will attack them wherever we see them," it said.
President Ashraf Ghani on Thursday declared an apparently unilateral week-long ceasefire with the Taliban.
It would last "from the 27th of Ramadan until the fifth day of Eid-al-Fitr", Ghani tweeted from an official account, indicating it could run from June 12-19.
The move came days after a gathering of Afghanistan's top clerics in the capital Kabul called for a ceasefire and issued a fatwa against suicide bombings and attacks.
An hour after the fatwa was issued, a suicide bomber detonated outside the gathering, killing seven people.
Ghani said his government supported the clerics' call.
"The government of Afghanistan not only supports the unanimous fatwa announcement by the ulemas (scholars), but also backs the recommended ceasefire," he said in a statement released by his office.
In February Ghani unveiled a plan to open peace talks with the Taliban, including eventually recognising them as a political party. At the time he also called for a ceasefire.
The insurgents did not officially respond, but announced the launch of their annual spring offensive in an apparent rejection of the plan, one of the most comprehensive ever offered by the Afghan government.
Last month, the Pentagon said that senior Taliban officials have been secretly negotiating with Afghan officials on a possible ceasefire.
Even such a brief cessation of hostilities would bring welcome relief to civilians in the war-torn country, nearly 17 years after the Taliban regime was toppled.
In recent years the resurgent militant group, along with the Islamic State group, have stepped up their attacks on Kabul in particular, making it the deadliest place in the country for civilians.