Dozens of young girls were buried on May 9 at a desolate hilltop cemetery in Kabul, a day after a secondary school was targeted in the bloodiest attack in Afghanistan in over a year.

A series of blasts outside the school during a peak holiday shopping period killed more than 50 people, mostly female students, and wounded more than 100 in Dasht-e-Barchi, a west Kabul suburb populated mostly by Hazara Shiites.

The government blamed the Taliban for the carnage, but the insurgents denied responsibility and issued a statement saying the nation needed to "safeguard and look after educational centres and institutions".

May 8's blasts came as the US military continues to withdraw its last 2,500 troops from the violence-wracked country despite faltering peace efforts between the Taliban and Afghan government to end a decades-long war.

Interior ministry spokesman Tareq Arian told reporters that a car bomb detonated in front of the Sayed al-Shuhada girls’ school on May 8, and when the students rushed out in panic, two more devices exploded.

Residents were shopping ahead of this week's Eid al-Fitr holiday – which marks the end of the Islamic holy month of Ramadan – when the blasts occurred.

On May 9, relatives buried the dead at a hilltop site known as "Martyrs Cemetery", where victims of attacks against the Hazara community are laid to rest.

Hazaras are Shiite Muslims and considered heretics by extremist Sunnis. Sunni Muslims make up the majority of the Afghan population.

Bodies in wooden coffins were lowered into graves one by one by mourners still in a state of shock and fear, an AFP photographer said.

"I rushed to the scene [after the blasts] and found myself in the middle of bodies, their hands and heads cut off and bones smashed," said Mohammad Taqi, a resident of Dasht-e-Barchi, whose two daughters were students at the school but had escaped the attack.

"All of them were girls. Their bodies piled on top of each other."

Last week the school's students had protested about a lack of teachers and study materials, said Mirza Hussain, a local resident.

"But what they got [in return] was a massacre."

Books and school bags belonging to the victims still lay scattered at the site of the attack.

Afghan officials including President Ashraf Ghani blamed the Taliban.

"This savage group does not have the power to confront security forces on the battlefield, and instead targets with brutality and barbarism public facilities and the girls' school," Ghani said in a statement after the blasts.

The Taliban denied involvement, and insist they have not carried out attacks in Kabul since February last year, when they signed a deal with Washington that paved the way for peace talks and withdrawal of the remaining US troops.

But the group has clashed daily with Afghan forces in the rugged countryside even as the US military reduces its presence.

The US was supposed to have pulled all forces out by May 1 as agreed with the Taliban last year, but Washington pushed back the date to September 11 – a move that angered the insurgents.

The leader of the Taliban, Hibatullah Akhundzada, reiterated in a message released ahead of Eid that any delay in withdrawing the troops was a "violation" of that deal.

"If America again fails to live up to its commitments then the world must bear witness and hold America accountable for all the consequences," Akhundzada warned in May 9's message.

He also said that the country should "safeguard and look after educational centres and institutions".

Pope Francis said May 8's attack was "an inhumane action", while Iran blamed the jihadist Islamic State (IS).

"By targeting children amid Ramadan, Daesh again exhibited its inhumanity and abject contempt for Islam and Muslims," Iranian foreign minister Javad Zarif said, calling IS by its Arabic acronym.

India called for "dismantling terrorist sanctuaries" and for a ceasefire to boost peace efforts.

On May 9 evening, Ghani declared a day of national mourning for May 11.

The Dasht-e-Barchi neighbourhood has been a regular target of attacks from Sunni Islamist militants.

Two brutal attacks last year on a hospital and a tuition centre in the same neighbourhood left about 50 people dead and scores wounded.