MOGADISHU, NOVEMBER 25

At least five people died and 23 others were injured after a huge explosion rocked Somalia's capital Mogadishu early on Thursday, triggering a plume of smoke which rose from the blast site amid gunfire, according to officials and a Reuters witness.

"So far we know five people died and 23 others (were) injured," Abdikadir Abdirahman, the director of Aamin Ambulance services, told Reuters.

Somalia Islamist group al Shabaab carried out the attack which was targeting a passing United Nations convoy, Abdiasis Abu Musab, the group's military operations spokesman told Reuters.

The blast near the K4 junction in the heart of Mogadishu was so large it collapsed the walls of the nearby Mucassar primary and secondary school and also left cars mangled.

"We were shaken by the blast pressure, then deafened by the gunfire that followed," said Mohamed Hussein, a nurse at the nearby Osman Hospital.

He added he had been pulled from the rubble of a collapsed ceiling.

"Our hospital walls collapsed. Opposite us is a school that also collapsed. I do not know how many died," he said.

Security officials could not be immediately reached for comment.

Al Shabaab has been fighting Somalia's central government for years to establish its own rule based on its strict interpretation of Islam's sharia law.

The group frequently carries out bombings and gun assaults in Somalia and elsewhere in its war against the Somalia military and the African Union-mandated AMISOM force that helps defend the central government.