At least 19 people were killed after two car bombs exploded outside the law courts in Somalia's capital Mogadishu and gunmen stormed the building.

A firefight erupted with security forces besieging the compound and there was a second blast while the shooting continued.

It was not immediately clear who carried out the attacks yesterday, but al Shabaab militants linked to al Qaeda have claimed responsibility for recent Mogadishu bombings.

"About seven well-armed men in government uniform entered the court today as soon as a car bomb exploded at the gate," said Aden Sabdow, a member of the mayor's office staff working next to the court. "We thought they were government soldiers."

Hussein Ali, who works at the courts, said : "Armed men entered the court and then we heard a blast. Then they started opening fire. We do not know the number of casualties."

It is not clear how many of the dead were soldiers, attackers or civilians.

Later, a car bomb exploded at a building housing Somali intelligence along the road to the airport as Turkish and African Union vehicles were passing.

Government forces opened fire and blocked the road.

Britain warned nine days ago that terrorists were planning attacks in Mogadishu.