The ceasefire, which is the first since the Taliban was driven from power in 2001, excludes operations against foreign based forces in Afghanistan and comes in the wake of a government ceasefire.
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.
The announcement came just hours after a fresh attack in the northern province of Kunduz in which 19 Afghan police officers were killed.
Taliban 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.
There was no immediate official response from the government but Omar Zakhilwal, Afghanistan's Ambassador to neighbouring Pakistan, described the announcement as an "important step towards prospects for peace".
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.
At least 19 Afghan police officers were killed on Saturday in a pre-dawn raid by the Taliban on a base in the northern province of Kunduz, officials said, hours before the militants announced an unprecedented ceasefire starting next week.
The Taliban claimed responsibility for the attack, which came a day after the insurgents stormed a military base in the western province of Herat, killing 17 Afghan soldiers.
Kunduz provincial governor spokesman Nehmatullah Taimuri said five members of the local police force were also wounded in Saturday’s attack on a police base in Qal-e-Zal district.
Provincial police spokesman Enhamuddin Rahmani confirmed the death toll and said eight Taliban fighters were also killed.