A blast outside a girls' school in an area of the Afghan capital populated largely by the Shiite Hazara community on Saturday killed more than 30 people including students and wounded scores more, officials said.

The explosion rocked the west Kabul district of Dasht-e-Barchi -- a regular target of Sunni Islamist militants -- as residents were out shopping ahead of next week's Eid-al-Fitr, which marks the end of Ramadan, the Muslim holy month of fasting.

It comes as the United States military continues to pull out its last 2,500 troops from violence-wracked Afghanistan, despite faltering peace efforts between the Taliban and Afghan government to end a decades-long war.

"More than 30 students and other countrymen have been killed, and over 50 more were wounded. The toll is rising." interior ministry spokesman Tareq Arian told reporters.

Afghan's capital has been rocked by violence as the United States continues its troop withdrawal
Afghan's capital has been rocked by violence as the United States continues its troop withdrawal AFP / WAKIL KOHSAR

Arian's deputy Hamid Roshan told AFP that an investigation had begun into the explosion.

"I saw many bloodied bodies in dust and smoke, while some of the wounded were screaming in pain," Reza, who escaped the blast, told AFP, adding that most of the victims were teenage girls who had just left the school.

"I saw a woman checking the bodies and calling for her daughter. She then found her daughter's blood-stained purse after which she fainted and fell to the ground."

Health ministry spokesman Dastagir Nazari said several ambulances had been rushed to the site to evacuate the wounded, adding that some in the angry crowd had beaten ambulance workers.

No organization immediately took responsibility for the attack, and the Taliban denied involvement.

The explosion rocked the west Kabul district of Dasht-e-Barchi -- a regular target of Sunni Islamist militants -- as residents were out for shopping ahead of Eid-al-Fitr
The explosion rocked the west Kabul district of Dasht-e-Barchi -- a regular target of Sunni Islamist militants -- as residents were out for shopping ahead of Eid-al-Fitr AFP / ZAKERIA HASHIMI

But President Ashraf Ghani blamed the group for the blast, which took place near the entry gate of Sayed Al-Shuhada girls' school.

"This savage group (Taliban) 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," he said in a statement.

The Taliban has denied carrying out attacks in Kabul since February last year, when they signed a deal with the United States that paved the way for peace talks and withdrawal of the remaining US troops.

An injured man is being brought on a stretcher to a hospital following a blast outside a school in the west Kabul district of Dasht-e-Barchi
An injured man is being brought on a stretcher to a hospital following a blast outside a school in the west Kabul district of Dasht-e-Barchi AFP / ZAKERIA HASHIMI

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

The United States was supposed to have pulled all forces out by May 1 under a deal struck with the Taliban last year, but Washington pushed back the date to September 11 -- a move that angered the insurgents.

The top US diplomat in Kabul, Ross Wilson, called the blast "abhorrent", tweeting: "With scores murdered, this unforgivable attack on children is an assault on Afghanistan's future, which cannot stand."

The European Union delegation in Afghanistan condemned what it said was a "despicable act of terrorism".

"Targeting primarily students in a girls' school, makes this an attack on the future of Afghanistan. On young people determined to improve their country," it said on Twitter.

The United Nations Assistance Mission in Afghanistan (UNAMA) expressed its "deep revulsion" at the blast.

And Pakistan's foreign ministry called the attack "reprehensible" and vowed to support Afghanistan in its peace efforts.

The Britain-based humanitarian organisation Emergency, which operates a surgical centre in Kabul, said it had received 26 people wounded in the blast.

"We are extremely concerned by this violence in Kabul and other parts of the country in recent weeks, following the announcement of the withdrawal of NATO troops," it said.

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

In May last year, a group of gunmen attacked a hospital in the area in a brazen daylight raid that left 25 people killed, including 16 mothers of newborn babies.

The hospital was supported by the international medical charity Doctors Without Borders, which later pulled out of the project.

No group claimed that attack, but Ghani blamed the Taliban and the jihadist Islamic State group.

On October 24, a suicide bomber blew himself up at a tuition centre in the same district, killing 18 people including students in an attack that also went unclaimed.