The armed group said on Saturday that the ceasefire would exclude foreign forces, and that it would defend itself against any attack.
It is the first such truce since the US-led invasion in 2001.
Ghani said fighting against other armed groups such as Islamic State of Iraq and the Levant (ISIL, also known as ISIS) will continue.
The surprise move by the government came days after a gathering of Afghanistan’s top religious leaders in the capital, Kabul, issued a fatwa – a religious edict issued by an expert in Islamic law – against suicide bombings and attacks.
The religious gathering was attacked on Monday by a suicide bomber, killing at least seven people.
The Taliban had denounced the gathering, insisting its fight against what it considers are foreign invaders was justified. It instead urged the religious scholars to side with it against the “occupation” of the country.
It was not immediately clear when the Taliban ceasefire would begin, as Eid starts when the moon is first sighted on either the 29th or 30th day of Ramadan, and the moon appears at different times across the country.
The Taliban’s statement added that the leadership of the Taliban may also consider releasing prisoners of war, if they promise not to return to the battlefield.
The US and NATO formally concluded their combat mission in Afghanistan in 2014, but the US still has thousands of forces based there in a support and counterterrorism role. The Trump administration has sent additional troops to try to change the course of America’s longest war.
Just hours before the Taliban’s Saturday announcement, at least 17 soldiers were killed when their checkpoint came under attack by the Taliban in western Herat province, said Gelani Farhad, spokesman for the provincial governor.
Farhad said one soldier was wounded. He added that eight Taliban attackers were killed and more than a dozen others were wounded during the gun battle.
In February, Ghani offered recognition of the Taliban as a legitimate political group in a proposed political process that he said could lead to talks to end more than 16 years of war.
Ghani proposed a ceasefire and a release of prisoners among a range of options including new elections involving the armed group, and a constitutional review in a pact with the Taliban to end a conflict that last year alone killed or wounded more than 10,000 Afghan civilians.
The Taliban has been fighting in Kabul since it was removed from power in 2001 by the US-led forces. The armed group has set the withdrawal of foreign forces as a pre-condition for peace talks.