Saeed Khatibzadeh condoled with Afghan people on the tragic incident.
“Dear Afghanistan once again was wounded by blind terrorism,” said the spokesman in a tweet.
“Afghan students fell victim to horrific violence and an endless war that they had never chosen,” he said.
“The Islamic Republic of Iran categorically condemns this heinous crime and express condolences to the Afghan nation and government,” the tweet read.
“Tonight, Iran is mourning the tragedy in Afghanistan,” he added in his tweet.
A roadside bomb in Kabul hit a passenger bus en route to the eastern city of Ghazni.
The spokesman for Ghazni governor, Waheedullah Jumazada, said nine civilians, including three women, were killed in the explosion.
Adam Khan Seerat, the Ghazni police spokesman, said four police officers were also wounded in the attack, which he blamed on the Taliban.
In another incident in Kabul, at least 13 people were killed when a bomber blew himself up at an education center.
Health Ministry spokesman Saeed Jami said authorities had recovered 13 bodies and transferred 30 injured people to hospital.
The Taliban have denied responsibility for the attack on the education center. The militant group has made no comment on the roadside bombing.