A large explosion outside a school in Somalia’s capital has killed at least eight people, including students, witnesses said.

The extremist group Al-Shabab said it carried out the attack.

The al Qaida-linked group controls large parts of rural Somalia and continues to frustrate efforts at rebuilding the African nation after three decades of conflict.

The blast sent a plume of smoke above a busy part of Mogadishu during the morning rush hour.

Police spokesman Abdifatah Adam Hassan said eight people were killed and 17 others wounded.

People search for bodies at the scene of a blast in Mogadishu
People search for bodies at the scene of the blast in Mogadishu (Farah Abdi Warsameh/AP)

“This is a tragedy,” said Abdulkadir Adan, of the Amin ambulance service, which rushed people to hospital.

The casualties were fewer than might have occurred as Thursday is part of the weekend in Somalia, an overwhelmingly Muslim nation.

Photos showed the blast damaged part of the school, with emergency workers looking through the collapsed roof beams and wooden benches.

Al-Shabab, in a statement carried by its Andalus radio service, said it targeted Western officials being escorted by the African Union (AU)peacekeeping convoy.

But a witness, Hassan Ali, said that a private security company was escorting the officials and said he saw four of the security personnel wounded.

The attack occurred as Somalia faces major questions about its political and security future.

The AU peacekeeping force was meant to withdraw from the country, but its mission could be extended amid concerns that Somali forces are not ready to assume responsibility for security.

A long-delayed presidential vote was meant to take place in February but now looks set to be held next year.