Several people killed in attempted breakout from Somalia prison
No prisoners had escaped and an investigation into how the attack occurred will be conducted, he added.
Eight people were killed in Somalia's capital Mogadishu after gunfire broke out between security forces and some prisoners who had acquired weapons and were trying to escape, state media and the prisons service said.
The firefight broke out in the capital's main prison, located in the city's south near the port.
During the operation five prisoners and three soldiers were killed while 21 people, majority of them inmates, were injured, Abdiqani Mohamed Qalaf, spokesperson for the prison service said on Facebook. He blamed "a violent group" among the prisoners for the attack.
No prisoners had escaped and an investigation into how the attack occurred will be conducted, he added.
'Explosion inside the cell'
"Somalia's prison forces concluded an operation in which prisoners fought inside the cell. Prisoners who tried to fight were shot dead," Somalia National TV said in a post on their Facebook account.
It said the inmates who died were members of the terrorist group Al Shabab who had been sentenced to death.
Two security personnel at the prison, who asked not to be named for fear of retribution, told Reuters grenades and guns had been smuggled into the cell and the inmates had used them to start the firefight.
"We heard gunfire and...explosion inside the cell. The gunfire stopped after like 15 minutes. Government forces cordoned (off) the whole area," said Abdullahi Aden, a local resident who lives near the prison.