Kabul: At least 37 people, the majority of them students, were killed when a suicide blast ripped through a school in Kabul Wednesday, officials said, the latest assault on Afghanistan's war-weary capital.

Around a dozen ambulances rushed to the Mawoud education centre in the western part of the city, where students and relatives described pulling bloodied victims from the rubble of a classroom that had been crowded with teenagers preparing to go to university.

"At around 4 pm this afternoon, a suicide attacker who had strapped explosives to his body detonated himself inside the Mawoud education centre," police spokesman Hashmat Stanikzai said.

"In the explosion 37 people were killed, more than 40 injured," he said, adding that the "absolute majority" of them had been students.

He warned the toll could rise.

Other officials have put it at as high as 48 people killed, with scores more injured.

It was not clear how many students were at the centre at the time of the attack.

One witness, another student named Ali Ahmad, said as many as 100 students may have been inside when the bomber struck, but officials have not yet confirmed the figure.

"My brother has been injured, possibly killed, because he wasn't breathing when I took his bloodied body out of the bloody, burning classroom," one man, who gave his name as Assadullah, said.

He had been nearby when he heard the blast, and ran to the centre, he told AFP.

His brother, Nusratullah, was around 17 years old, he said, sobbing over the phone.

"He was a smart and energetic boy, top of his class," Assadullah said. "Now... I am not sure he will survive."

There was no immediate claim of responsibility for the attack, which was swiftly condemned by President Ashraf Ghani in a statement.

Both the Taliban and Daesh have carried out devastating, high-profile attacks in Kabul in recent months, but the Taliban quickly denied they were involved.

Grinding conflict

The assault underscores the price that ordinary Afghans have paid in the grinding conflict as the country reels from a recent upsurge in militant violence, including a massive, days-long Taliban onslaught on the eastern city of Ghazni.

Afghan forces appeared to have finally pushed Taliban fighters from the strategic provincial capital on Wednesday, as shopkeepers and residents warily returned to the streets after days of intense ground fighting and US airstrikes.

Security forces were on patrol and no militants were in sight in the centre of the shattered city, with fighting which began late Thursday seeming to have finally ceased.

But analysts said the Taliban had scored a military and psychological victory against Kabul in Ghazni, proving they have the strength to strike a strategically vital city near the capital at will and remain entrenched there for days.

The fall of a northern base this week, with at least 17 soldiers killed, was a further blow to Afghan security forces, already demoralised by staggering casualties.

"What we've seen over the last few days is a microcosm of the war in Afghanistan - overmatched Afghan troops, emboldened Taliban fighters, and American forces that eventually come in to help bail the Afghans out," analyst Michael Kugelman of the Wilson Center in Washington told AFP.

"What's crystal clear is that nearly four years after the Afghan security forces took over the war efforts, they're still woefully unprepared for the task - despite very real improvements in capacities in recent years."

That gives the government a strong incentive to build on recent, tentative signs that diplomatic efforts to kick-start peace negotiations are starting to bear fruit, he said.

But for the insurgents, Ghazni in particular was being seen as a show of strength. "For the insurgents, the thinking is, 'why quit when we're ahead'?" Kugelman said.

At least 100 security forces were killed in the fight for Ghazni, officials have said, with unconfirmed fears that at least as many civilians died.

The surge in violence comes weeks after Afghans marked an unprecedented country-wide ceasefire between the Taliban and government forces in June, giving some relief to war-weary civilians.

It also comes as US and Afghan forces intensify ground and air offensives against Daesh, and the Taliban step up their turf war with the group.

The Taliban have not claimed a major assault in Kabul for weeks.

Daesh, however, has carried out multiple attacks in the eastern city of Jalalabad and the capital in recent months, and has increasingly targeted the Shiite minority.

Earlier this month, Daesh claimed responsiblity for twin blasts at a mosque in the eastern city of Gardez that killed at least 35 people.

UAE condemns Kabul blast

Afghanistan: The United Arab Emirates has condemned the terror blast that occurred in an educational facility in Afghanistan, and left a number of innocent victims. The Ministry of Foreign Affairs and International Cooperation (MoFAIC) expressed the country's vehement condemnation of these acts of terror, reaffirming the UAE's categorical rejection of all forms of violence and terrorism. In a statement today, MoFAIC reiterated the UAE's solidarity and support to the Republic of Afghanistan in countering violence and extremism and called upon the international community to close ranks and uproot the evil of terrorism, which threatens international peace and stability. The ministry extended the condolences of the UAE to the families of the victims and wished a speedy recovery to the injured.

– WAM