At least six prisoners were killed and six others wounded in a shoot-out inside a prison in the Somali capital, Mogadishu on Monday.
There were conflicting reports of how the prisoners, all said to be members of the al-Qaeda-linked group al-Shabab, got hold of the weapons."There was heavy shooting inside the prison where some inmates managed to get hold of firearms and started shooting the guards," security officer Abdi Dhere told the AFP news agency.
"It is not clear how the prisoners ended up having access to guns."
Another security source said one of the prisoners snatched a rifle from a guard.
Two prison guards were killed in the attack, General Mahad Abdirahman Aden, the country's prison chief, told national TV.
Information ministry spokesman Ismael Mukhtar Omar said the situation in the prison was now back to normal.
"All those inmates who were involved in the fighting were killed," he said in a statement.Hassan Kulmiye, a police officer, told DPA news agency the prisoners were able to capture parts of the complex and it took security forces nearly two hours to end the siege.
Somalia has been embroiled in deadly violence since 1991, when clan fighters overthrew longtime leader Siad Barre and then turned on each other.
Since 2008, al-Shabab has been fighting to overthrow the internationally-recognised central government and establish its rule based on its own interpretation of Islamic law.
Al-Shabab was driven out of the capital in 2011 by Somali forces backed by African Union troops, but has continued to wage war against the government, carrying out regular attacks.
Last month, Somalia's military chief escaped unhurt when an al-Shabab suicide attacker drove a bomb-laden car into his convoy in Mogadishu.