At least 26 people have been killed following a car bomb at a gathering of Taliban and Afghan armed forces in the eastern city of Nangarhar, as soldiers and militants in the country celebrated an unprecedented ceasefire.

Dozens of unarmed Taliban militants had earlier entered the Afghan capital and other cities to celebrate, coinciding with the end of the Ramadan fasting season, as soldiers and militants exchanged hugs and took selfies on their smartphones.

But in some provinces the insurgents were carrying rocket launchers, grenades and other ammunition.

A spokesman for the provincial governor of Nangarhar confirmed a car bomb was responsible for the attack in the town.

The spokesman had earlier said a rocket-propelled grenade was to blame.

So-called Islamic State has claimed responsibility for the attack, according to the group's Amaq news agency.

The agency said the attack targeted "a gathering of Afghan forces" in Nangarhar but gave no details.

The Taliban announced a surprise three-day ceasefire over the Eid holiday, which began on Friday, except against foreign forces.

It overlaps with an Afghan government ceasefire which lasts until Wednesday.

Afghanistan also faces insurgencies from so-called Islamic State and the Taliban-linked Haqqani network.

Taliban forces wearing traditional headgear entered Kabul through gates in the south and southeast.

Traffic jams formed where people stopped to take pictures of the fighters with their flags.

The Taliban urged people to come forward and take selfies.

"They are unarmed, as they handed over their weapons at the entrances," a Kabul police spokesman said.

Their weapons would be returned when they leave, he added.

Interior Minister Wais Ahmad Barmak met Taliban fighters in Kabul, Tolo news said, an almost unthinkable prospect just two weeks ago.

Video and pictures on news websites showed cheerful soldiers and Taliban hugging one another and exchanging Eid greetings.

Members of rights groups organised a brief meeting between Afghan forces and Taliban insurgents in Helmand's capital city, where the Taliban have delivered a series of blows to government forces this year.

Men and women gathered around the soldiers and Taliban fighters and urged them to keep their weapons holstered before they hugged each other.

The main square of Kunduz city, capital of the province of the same name, which has witnessed a series of bloody clashes, became a friendly meeting ground.

Photos on news websites showed armed police standing in line at the corner of the street hugging Taliban fighters one by one.

A video showed a huge crowd of people screaming and whistling as they welcomed the Taliban.

In some districts of the eastern city of Jalalabad, civilians were offering dry fruit, traditional sweets and ice cream to Taliban militants.

President Ashraf Ghani expressed hope on Friday that the ceasefire would make way for a lengthier halt in the fighting and called for the Taliban to come to the negotiating table.