Afghanistan's President Ashraf Ghani announced on Thursday a temporary ceasefire with Taliban until June 20, though it was not immediately clear if the armed group had agreed.

In a televised address, Ghani said that fighting against other armed groups such as Islamic State of Iraq and the Levant (ISIL) will continue.

The Afghan president told security forces to cease operations against the armed group until June 20 after fasting month ends.

The ceasefire will last "from the 27th of Ramadan until the fifth day of Eid-ul-Fitr," the president tweeted from an official account, indicating it could run from June 12-19.

"This ceasefire is an opportunity for Taliban to introspect that their violent campaign is not winning them hearts and minds but further alienating," he said in a Tweet.

"With the ceasefire announcement we epitomise the strength of the Afghan government and the will of the people for a peaceful resolution to the Afghan conflict."

The surprise move comes 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 by a suicide bomber in which at least seven people were killed.

Ghani in February 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.