The blast which occurred in the Dasht-e-Barchi neighbourhood of western Kabul, a predominantly Shia Muslim area home to the minority Hazara community, according to police spokesman Khalid Zadran.
"Students were preparing for an exam when a suicide bomber struck at this educational centre," he said.
He had put the death toll initially at 19 but later reports indicate that at least 32 people have been killed in the attack.
Videos posted online and photos published by local media showed bloodied victims being carried away from the scene.
The victims included high school graduates, both girls and boys, who were taking a practice university entrance exam at the Kaj education centre when the blast went off, Zadran said. Schools are typically closed in Afghanistan on Fridays.
“Attacking civilian targets proves the enemy’s inhuman cruelty and lack of moral standards,” he said, without specifying who was believed to be behind the attack.
One wounded student said the victims were mostly girls.
“We were around 600 (students) in the classroom, but most of the casualties are among girls,” the male student told the AFP news agency from the hospital where he was being treated.
No group immediately claimed responsibility.
Families rushed to area hospitals where ambulances were arriving with victims and lists of those confirmed dead and wounded were posted to the walls.
“We didn’t find her here,” said a distressed woman looking for her sister at one of the hospitals. “She was 19 years old.”
Resident Ghulm Sadiq said he was at home when he heard a loud sound. He went outside to see smoke rising from the education centre where he and neighbours rushed to help.
“My friends and I were able to move around 15 wounded and nine dead bodies from the explosion site … Other bodies were lying under chairs and tables inside the classroom,” he said.
Further details of the attack were not immediately available, although the official death toll was expected to rise.
Ethnic Hazara have alleged years of persecution by the ruling Taliban, which returned to power in the country following the withdrawal of United States-led forces in August 2021, and have been the victims of several attacks claimed by the rival ISIL (ISIS) group.
The Dasht-e-Barchi neighbourhood has witnessed some of the worst attacks in Afghanistan in recent years.
In 2021, before the Taliban takeover, at least 85 people – mostly female students – were killed and about 300 others wounded when three bombs exploded near their school in Dasht-e-Barchi.
No group claimed responsibility for that attack, but a year earlier, ISIL claimed responsibility for a suicide attack on an educational centre in the same area that killed 24, including students.
Since taking control, the Taliban government has emphasised that it is securing the nation following decades of war, but a series of attacks on mosques and civilian areas in recent months has challenged that narrative.
Education also remains a flashpoint issue in Afghanistan with the Taliban blocking many girls from returning to secondary education. ISIL also stands against the education of women and girls.
Source: Al Jazeera