At least 16 people were killed as two car bombs exploded outside the law courts in Somalia's capital Mogadishu and gunmen stormed the building.
Somali forces arrived and besieged the court compound and there was a second blast while shots rang out.
It was not immediately clear who carried out the attack, but al-Shabaab militants linked to al-Qaeda have claimed responsibility for a number of suicide bombs in Mogadishu this year.
Reuters reporters counted 16 bodies, some of them in uniform, some not, around the compound, but it was not clear how many of them were government soldiers, attackers, or civilians.
A large blast was also heard near Mogadishu airport shortly after the attack on the courts.
Witnesses said a bomb exploded at a building housing Somali intelligence along the road to the airport as Turkish and African Union vehicles were passing.
Last month, al-Shabaab claimed responsibility for suicide car bomb targeting a senior Somali security official which killed at least ten people in central Mogadishu.
The security official survived the attack.
Britain warned on 5 April it believed "terrorists are in the final stages of planning attacks in Mogadishu".