“A suicide bomber wanted to enter the education centre,” interior ministry spokesman Tareq Arian said in a statement.
“But he was identified by the centre’s guards, after which he detonated his explosives in an alley.”
He confirmed the attack had killed 18 people and wounded 57.
The extremist Islamic State group subsequently claimed responsibility for the attack.
A suicide bomber “set off towards a gathering... in Kabul, where he detonated his explosives jacket” in the crowd, IS said in a statement posted on its social media channels.
Witness Ali Reza said the blast sent dust and smoke swirling all around him.
“I was standing about 100 metres from the centre when a big blast knocked me down,” said Reza, who had gone to hospital with his cousin, who was wounded in the blast.
“Dust and smoke were all around me. All those killed and wounded were students who wanted to enter the centre.”
Residents later gathered at the site where pools of dried blood could be seen where the bomber had detonated his explosives-laden vest.
Residents in several districts of western Kabul belong to the minority Shiite Hazara community, and are often targeted by Sunni extremists of IS.
‘World must take notice’
In the past, extremists have targeted several education centres and other facilities in the area.
In May, a group of gunmen launched a brazen daylight attack on a hospital in west Kabul that left several mothers dead. The gunmen were shot dead after hours of fighting with security forces.
Washington blamed IS for that attack.
Saturday’s suicide attack came hours after a roadside bomb tore through a bus east of the capital, killing nine civilians. Officials blamed the Taliban for attack on bus.
The office of President Ashraf Ghani appeared to blame the Taliban for the overall bloodshed that rocked Afghanistan on Saturday and in recent weeks.
Despite frequent calls on the insurgent group for a ceasefire, “the Taliban still continue to escalate violence and protract their illegitimate war,” it said in a statement released hours after the suicide attack in Kabul.
On Friday, rights group Amnesty International said at least 50 people had been killed in attacks in the preceding week, accusing both the Taliban and the government of failing to protect civilians.
“The world must sit up and take notice. Afghan civilians are being slaughtered on a daily basis,” said Omar Waraich, Amnesty’s head of South Asia.
“The international community must make the protection of civilians a core demand for their ongoing support of the peace process.”
Despite holding peace talks with government negotiators in Doha since last month, the Taliban have only increased violence, in a bid to wield leverage at the bargaining table.
The top US envoy to Afghanistan, Zalmay Khalilzad, said earlier this week that fighting was threatening the peace process.
US influence over Afghanistan’s battlegrounds is on the wane, however, with the Pentagon looking to withdraw all its remaining troops by next May.
The Taliban have been quick to exploit the apparent lack of resolve, and began to push for fresh military gains as soon as they signed a withdrawal deal with the US in February.